wp_get_attachment_image_src() width and height boolean

I have the following code in my theme:

<?php
$size = 'large';
$postimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $size );
$url = $postimage[0];
$h = $postimage[2]
?>

<div style="background-image: url(<?php echo $url; ?>); height: <?php echo $h; ?>;"></div>

Here’s an example var_dump output for $postimage:

Read More
array(3) {
 [0]=> string(99) "{base url here}/uploads/2013/10/h3greendeck.jpg?fit=660%2C660"
 [1]=> bool(false)
 [2]=> bool(false)
}

If I remove the size argument for wp_get_attachment_image_src() to let it use default I get the same result. Why is size returning boolean, when WordPress knows the size of the image? This happens for every single instance of this code, regardless of the post I’m viewing.

Related posts

Leave a Reply

1 comment

  1. This sounds like a description of the JetPack’s Photon service.

    Photon is an image acceleration and modification service for
    Jetpack-connected WordPress sites. Converted images are cached
    automatically and served from the WordPress.com CDN. Images can be
    cropped, resized, and filtered by using a simple API controlled by GET
    query arguments. When Photon is enabled in Jetpack, images are updated
    on the fly.

    The Photon API includes the fit GET parameter:

    http://i0.wp.com/example.com/wp-content/uploads/2014/04/abc.jpg?fit=600%2C400
    

    where %2C is url encoded comma.

    It uses the image_downsize filter to overwrite the image retrevial with:

    // Generate Photon URL
    $image = array(
        jetpack_photon_url( $image_url, $photon_args ),
        false,
        false
    );
    

    where the width and height are set to false.