• Resolved assortedchips

    (@assortedchips)


    For this problem, let’s assume I have an image has dimensions width=517px and height=618px.

    I upgraded to WP 4.4. Using my own child theme with TwentyFifteen parent.

    I have a plugin (DrawIt) where I use media_handle_sideload() to upload image data, then use wp_get_attachment_image() to get the HTML for the image. It returns the responsive image HTML (with srcset and sizes attributes), and does this correctly for images shorter than 510px. However, if the original image was taller than 510px, such as the example of 517×618, then the srcset attribute does not include the original image URL as the option for the srcset 517w option. Instead, it uses a height-cropped version of 517×510 for the srcset 517w option. It should only show the full image, not the cropped image. I am calling wp_get_attachment_image() with the “full” argument.

    Here’s how I get the image HTML:
    $img_html = wp_get_attachment_image($attach_id, 'full', false);

    Here’s what it returns:
    <img width="517" height="618" src="https://example.com/deleteme.png" class="aligncenter wp-image-1277" alt="deleteme" title="deleteme" srcset="https://example.com/deleteme-251x300.png 251w, https://example.com/deleteme-517x510.png 517w" sizes="(max-width: 517px) 100vw, 517px" />

    Since the 517w option lists the cropped version, in a large browser window the image never shows the full image, it only shows the cropped image.

    Here’s what it should have returned:
    <img width="517" height="618" src="https://example.com/deleteme.png" class="aligncenter wp-image-1277" alt="deleteme" title="deleteme" srcset="https://example.com/deleteme-251x300.png 251w, https://example.com/deleteme.png 517w" sizes="(max-width: 517px) 100vw, 517px" />

Viewing 1 replies (of 1 total)
  • Thread Starter assortedchips

    (@assortedchips)

    Problem solved.

    I am using WP Offload S3 plugin. Just a moment ago I got the notification that there is an update for it that fixes this problem.

Viewing 1 replies (of 1 total)
  • The topic ‘WP 4.4 responsive image shows height-cropped images when taller than 510px’ is closed to new replies.