Support » Plugin: Jetpack by WordPress.com » Jetpack (Photon) breaks core function wp_get_attachment_image_src
3 years, 10 months ago
In the latest version of Jetpack, wp_get_attachment_image_src() returns empty values for width and height with Photon enabled.
Disabling Photon fixes the issue at the cost of losing the performance benefits of the Photon service. I have seen this behavior on multiple sites I maintain.
I can’t begin to express how frustrating it is that a plugin (especially by Automattic!) would break a core function in this way.
My solution was to change my code to use PHP’s getimagesize() function to get the proper values (which is what the core function should be doing anyway.)
$image_src = wp_get_attachment_image_src($post_thumbnail_id);
$image_url = $image_src;
@list($image_w, $image_h) = getimagesize($image_url);
Is there a better solution?
3 years, 9 months ago
That is indeed a necessary side-effect of using Photon. You can read more about it here:
Thanks for the reply, Jeremy.