[wp-trac] [WordPress Trac] #36982: Add image attributes and additional context to the wp_calculate_image_srcset and wp_calculate_image_sizes filters

WordPress Trac noreply at wordpress.org
Wed Dec 23 20:18:06 UTC 2020


#36982: Add image attributes and additional context to the
wp_calculate_image_srcset and wp_calculate_image_sizes filters
-----------------------------------+------------------------------
 Reporter:  kylereicks             |       Owner:  adamsilverstein
     Type:  enhancement            |      Status:  assigned
 Priority:  normal                 |   Milestone:  5.7
Component:  Media                  |     Version:  4.6
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:  template
-----------------------------------+------------------------------

Comment (by adamsilverstein):

 @kylereicks I couldn't quite understand the regex your patch includes to
 extract the image attributes. Can we just ''not pass attributes'' in that
 case? Developers still get the source and could extract attributes if they
 need them.

 If we do want to try to extract the attributes, I would ask:
 * Document the RegEx part by part so it can be understood more easily.
 * Move the attribute extraction into a helper.
 * Add tests that validate the helper works correctly in all cases.

 Otherwise this patch looks good: when we have the image attributes, we
 pass them to the `wp_calculate_image_sizes` and
 `wp_calculate_image_srcset` filters to make those filters more useful for
 developers.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/36982#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list