Jetpack by WordPress.com
[resolved] Jetpack (Photon) breaks core function wp_get_attachment_image_src (3 posts)

  1. dgrundel
    Posted 3 years 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[0];
    @list($image_w, $image_h) = getimagesize($image_url);

    Is there a better solution?


  2. Jeremy Herve
    Jetpack Mechanic
    Plugin Author

    Posted 3 years ago #

    That is indeed a necessary side-effect of using Photon. You can read more about it here:

  3. dgrundel
    Posted 3 years ago #

    Thanks for the reply, Jeremy.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Jetpack by WordPress.com
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic