I have the following code in my theme:

$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:

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.

  • 1
    That fit= argument is not something I recognize. I have to assume there is a plugin involved, or a theme. Disable your plugins and switch to a bundled theme. Do you still have this problem? – s_ha_dum Apr 9 '14 at 14:37
  • Seems that some code, probably a plugin, is filtering wp_get_attachment_image_src to append that 'fit' query variable and possibly same code is the culprit of this weird behavior – gmazzap Apr 9 '14 at 15:47

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:


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 ),

where the width and height are set to false.

  • 1
    That was the problem, thanks! Disabling Photon gave me valid dimensions. – Christiaan Apr 9 '14 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.