function test_apply_parameters_to_url_with_mismatched_url() { $result = apply_parameters_to_url("https://assets.imgix.net/cats-400x300.gif?someotherquery=400", "w=400&h=300", "<img src=\"https://assets.imgix.net/DOGS-400x300.gif?my-param=399\" />"); // TODO we should not be encoding ampersands as & within src attributes $this->assertEquals('<img src="https://assets.imgix.net/DOGS-400x300.gif?my-param=399" />', $result); }
function imgix_replace_non_wp_images($content) { list($content, $match) = replace_host($content, true); if ($match) { //Apply image-tag-encoded params for every image in $content. foreach (imgix_extract_img_details($content) as $img) { $to_replace = $img['raw']; $extra_params = $img['extra'] ? '&' . $img['extra'] : ''; $new_url = '.' . $img['type'] . '?h=' . $img['h'] . '&w=' . $img['w'] . $extra_params; $content = str_replace($to_replace, $new_url, $content); } // Apply global parameters. $g_params = get_global_params_string(); foreach (imgix_extract_imgs($content) as $img_url) { $content = apply_parameters_to_url($img_url, $g_params, $content); } } return $content; }