WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
[resolved] [closed] wp_get_attachment_image_src full image issues (5 posts)

  1. macgamer
    Member
    Posted 1 year ago #

    if I do wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');, I get an array with a couple of issues.

    First of all, no height or width is returned.
    Secondly the URL has a resize string at the end.

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

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    Could you give me a few examples of the returned Photon URLs?

    If you could give us a link to your site as well, that might be useful!

    Thanks.

  3. macgamer
    Member
    Posted 1 year ago #

    Sure, if you look in the <head> section of this page: http://www.controlcommandescape.com/games/borderlands-2/

    you'll see

    <meta property="og:image" content="http://i2.wp.com/www.controlcommandescape.com/wp-content/uploads/2012/11/borderlands2.png?resize=1024%2C1024" />
    <meta property="og:image" content="http://i1.wp.com/www.controlcommandescape.com/wp-content/uploads/2012/11/2012-11-17_00002.jpg?resize=1920%2C1080" />

    and no dimensions are returned for either image

  4. Erick Hitter
    Member
    Plugin Author

    Posted 1 year ago #

    Hello,

    The lack of width and height in the data returned by wp_get_attachment_image_src() is a necessary side-effect of using Photon.

    At present, Photon has no way of informing WordPress of the dimensions of an image it resizes. While there are many cases where the size of the image received from Photon matches the requested size, there are also cases when this won't be true. This depends largely on the size of the original image and whether or not the image size dictates cropping be applied.

    As a result, the module sets WordPress' image functions to return false when an image is processed with Photon. This avoids image skewing and prevents WordPress from returning misinformation about the resized image.

    Hope this helps explain what's happening with wp_get_attachment_image_src().

    As for the resizing parameters on the og:image meta tag, that problem should've been fixed in Jetpack 2.2. We'll investigate why that isn't working properly and update this thread once it is fixed in Jetpack.

  5. macgamer
    Member
    Posted 1 year ago #

    ok thanks for the info. Is there a simple way to use wp_get_attachment_image_src() without using photon? I.e. I could use it once (without photon) to grab the image dimensions from the local full-size image, and then again (with photon) to actually grab the image url?

    Edit: Never mind, I see you've answered this on my other thread!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.