[wp-trac] [WordPress Trac] #46155: Responsive images (srcset) not working on cropped files.

WordPress Trac noreply at wordpress.org
Thu Jan 31 02:51:55 UTC 2019


#46155: Responsive images (srcset) not working on cropped files.
--------------------------+-----------------------------
 Reporter:  olgri         |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  major         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When adding images to a page or using wp_get_attachment_image() function
 in a page template, responsive images do not get generated if the image
 size is set to 'crop' (e.g. thumbnail or a custom size). Basically, srcset
 is not added in html. Other sizes are OK though.

 To reproduce the bug, make sure an image size is set to 'crop'. Then
 upload a new image and add it to a page selecting a **full size first**.
 Update the page and then remove the image from the page. Update and then
 insert it again and this time make sure to select the **cropped image
 size**. Update.
 You will see that a standard <img> tag is generated in the frontend. E.g.:

 {{{
 <img class="alignnone size-thumbnail wp-image-10" src="/wp-content/uploads
 /photo-360x360.jpg" alt="" width="360" height="360">
 }}}

 instead of

 {{{
 <img class="alignnone size-thumbnail wp-image-10" src="/wp-content/uploads
 /photo-360x360.jpg" alt="" width="360" height="360" srcset="/wp-
 content/uploads/photo-360x360.jpg 360w, /wp-content/uploads/photo-
 720x720.jpg 720w, /wp-content/uploads/photo-768x768.jpg 768w, /wp-
 content/uploads/photo.jpg 1280w" sizes="(max-width: 360px) 100vw, 360px">
 }}}


 I have tested it on WP 5.0.3 and even tried downgrading to 4.9.9 and 4.9.8
 but it's the same. Tested with all plugins deactivated and on the default
 twenty-something theme.
 I have tried it on PHP 7.1, 7.2 and 5.6.
 Tested both Guttenberg and the classic editor.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46155>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list