Make WordPress Core


Ignore:
Timestamp:
11/20/2024 02:31:02 PM (11 days ago)
Author:
desrosj
Message:

Media: Avoid images with sizes=auto to be displayed downsized in supporting browsers.

Based on the user agent stylesheet rules outlined in https://html.spec.whatwg.org/multipage/rendering.html#img-contain-size, images that have sizes=auto while applying width: auto or width: fit-content would be constrained to only 300px width.

This changeset overrides said user agent stylesheet rule with a much larger constraint, to avoid the problem.

Additionally, it introduces a filter wp_img_tag_add_auto_sizes which can be used to opt out of the functionality, as an additional measure.

Reviewed by desrosj, joemcgill.
Merges [59415] to the 6.7 branch.

Props joemcgill, flixos90, dooperweb, SirLouen, azaozz, mukesh27, apermo.
Fixes #62413.
See #61847, #62345.

Location:
branches/6.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.7

  • branches/6.7/src/wp-includes/default-filters.php

    r59120 r59435  
    612612add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
    613613
     614add_action( 'wp_head', 'wp_print_auto_sizes_contain_css_fix', 1 );
    614615add_action( 'wp_head', 'wp_maybe_inline_styles', 1 ); // Run for styles enqueued in <head>.
    615616add_action( 'wp_footer', 'wp_maybe_inline_styles', 1 ); // Run for late-loaded styles in the footer.
Note: See TracChangeset for help on using the changeset viewer.