[wp-trac] [WordPress Trac] #45407: Add block attributes to `wp_calculate_image_sizes` to allow for proper handling of `sizes` attribute

WordPress Trac noreply at wordpress.org
Mon Jan 7 19:01:53 UTC 2019


#45407: Add block attributes to `wp_calculate_image_sizes` to allow for proper
handling of `sizes` attribute
--------------------------+---------------------
 Reporter:  mor10         |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  5.1
Component:  Media         |     Version:
 Severity:  major         |  Resolution:
 Keywords:  dev-feedback  |     Focuses:
--------------------------+---------------------

Comment (by mor10):

 Replying to [comment:19 youknowriad]:
 > I suggest we stop thinking about stop-gap fixes and think about a more
 future-proof solution that doesn't involve tweaks from the theme.

 As I've explained before, the current code shipped is incorrect and causes
 browsers to use the wrong image sources for different displays. This is
 non-trivial and deserves to be resolved immediately. The current
 methodology for handling responsive images is controlling the `sizes`
 attribute via themes. This has been the standard method since 2015 and it
 is one employed by all default themes including Twenty Nineteen.

 While I agree this is a sub-optimal solution, it is the status quo. What
 I'm asking for is to get core updated so the current recommended
 methodology works correctly. As stated, it does not at the moment for all
 the reasons listed earlier in the ticket.

 >
 > Some ideas:
 >
 >  - Remove the image size picker
 Not related to this ticket.
 >  - Add a new default image size in WordPress (big one)
 Yes,
 >  - A way for themes and block containers to define which size to use by
 default for each alignment option. For example, when a user makes an image
 "wide", the default "src" used switches to the big image size which means
 the filter will adjust the sizes attribute accordingly.
 Not a viable solution to the current problem because themes must have a
 way of defining, per layout, what those widths are.

 Responsive images markup (`srcset` and `sizes`) ''does not'' control the
 layout of the page, it informs the browser what source file to load based
 on the eventual displayed width in advance of paint so the browser doesn't
 download an incorrectly sized image for the layout once CSS is rendered.
 Thus the information about layout width ''must'' come from the theme since
 the theme is the only code with knowledge of the eventual width of any one
 image.

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


More information about the wp-trac mailing list