ResponsiveImagesCG / wp-tevko-responsive-images

Fully responsive image plugin for wordpress
449 stars 53 forks source link

`the_post_thumbnail()` not returning `srcset` attributes. #232

Closed joemcgill closed 8 years ago

joemcgill commented 8 years ago

See this support thread at WP.org.

The gist of the issue is that the_post_thumbnail() passes the named size post-thumbnail to get_the_post_thumbnail() which, in turn, uses wp_get_attachment_image() to build the markup. In core, we are converting the returned size to a size array before calling wp_calculate_image_srcset() but in the plugin we are filtering the wp_get_attachment_image_attributes and are passing the size name to wp_get_attachment_image_srcset().

Perhaps we should transform the named size into an array an use wp_calculate_image_srcset() in tevkori_filter_attachment_image_attributes() to be consistent, but I also wonder if we should allow unnamed sizes passed to wp_get_attachment_image_srcset() to fall back to the full size image to be consistent with the behavior of wp_get_attachment_image().

joemcgill commented 8 years ago

Actually, wp_get_attachment_srcset() does fall back to the full size image, but wp_get_attachment_sizes() returns false, which is why the attributes are not being added.

jaspermdegroot commented 8 years ago

This issue only happened if no post thumbnail size was specified with set_post_thumbnail_size(). The problem has been fixed already in branch dev by commit 27d1b5367fc4a8d5ba05652e0c4e28567f21c6da where the sizes function has been split into two functions.