コード例 #1
0
 function test_replace_host_with_require_prefix_and_match_with_double_quote()
 {
     global $imgix_options;
     $imgix_options = array('cdn_link' => "https://assets.imgix.net");
     $result = replace_host("src=\"" . home_url('image-400x300.png') . "\"", true);
     $this->assertEquals(array("src=\"https://assets.imgix.net/image-400x300.png\"", true), $result);
 }
コード例 #2
0
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;
}