WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. dgrundel
    Member
    Posted 1 year 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?

    http://wordpress.org/extend/plugins/jetpack/

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    That is indeed a necessary side-effect of using Photon. You can read more about it here:
    http://wordpress.org/support/topic/wp_get_attachment_image_src-full-image-issues?replies=5#post-3950332

  3. dgrundel
    Member
    Posted 1 year ago #

    Thanks for the reply, Jeremy.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic