[wp-trac] [WordPress Trac] #34736: wp_calculate_image_srcset filter: provide the individual srcset image size

WordPress Trac noreply at wordpress.org
Thu Nov 19 21:49:10 UTC 2015


#34736: wp_calculate_image_srcset filter: provide the individual srcset image size
--------------------------+-----------------------------
 Reporter:  kraftbj       |       Owner:  joemcgill
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  Future Release
Component:  Media         |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+-----------------------------
Changes (by joemcgill):

 * milestone:  4.4 => Future Release


Comment:

 > It strikes me as odd to include the width twice -- both as a key, and in
 the size -- but I can see how it'd be easier to work with.

 I agree that including the width multiple times in the same array is
 awkward. If we make this change, we essentially have the width listed
 three times: the array key for each source, the value of each source, and
 again in a size array. We could only add a height value to each source
 instead of size array, but it seems equally awkward to have a height value
 without a width value. Additionally, if `h` descriptors ever become
 supported by browsers—something that has been requested—we'd run into this
 all over again, but from the opposite perspective.

 I spoke with @kraftbj and came up with an alternate solution for their
 specific use case, which is the use the `$size_array` of the `src` image
 to calculate the image ratio, and then applying the ratio to the source
 value to calculate the height of each source image.

 Since there is a decent workaround, I'm going to punt this to a future
 release rather than rushing this for RC1. If we receive more feedback that
 passing the height for each source would be helpful to developers, then we
 can revisit.

 Somewhat unrelated, the `@type` doc fixes from [attachment:34736.3.patch]
 should probably go in. Either @DH-Shredder or I will create a new patch
 for that change on #34733.

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


More information about the wp-trac mailing list