Jetpack issue submitted: https://github.com/Automattic/jetpack/issues/2281

If you do this:

$attachmentImage = wp_get_attachment_image_src( 1234, 'full' );
$url = $attachmentImage[0];
$width = $attachmentImage[1];
$height = $attachmentImage[2];

$width and $height should give out the image dimensions, but when Photon is activated, both don’t get returned.

The workaround for this is discussed here:https://wordpress.org/support/topic/wp_get_attachment_image_src-changed?replies=5#post-3950371

The workaround is to get the dimensions without Photon, then get the image URL normally:

add_filter( 'jetpack_photon_override_image_downsize', '__return_true' );
$imageInfo = wp_get_attachment_image_src( 1234, 'full' );
remove_filter( 'jetpack_photon_override_image_downsize', '__return_true' );

$attachmentImage = wp_get_attachment_image_src( 1234, 'full' );
$url = $attachmentImage[0];
$width = $imageInfo[1];
$height = $imageInfo[2];

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*