Opened 15 months ago
Last modified 15 months ago
#58631 new defect (bug)
decoding="async" is added wildly, even if loading="eager" is there
Reported by: | vyskoczilova | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.2.2 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
Could we do something about decoding="async"
parameter being added wildly on EVERY image?
It might seem to be a good idea, but it's not. I'm developing custom themes, and although it was introduced in 6.1, it touched me probably with some changes in 6.2 where wp_filter_content_tags()
is replacing images without the parameter (and wp_get_attachment_image_attributes
filter is not called in this case. I was using loading="eager" for my hero images (rendered in the template via Timber) which should be a no-no to adding decoding="async" for that.
I might help to fix the issue if somebody guides me through track and svn (but I'm fluent in git repos if there is finally a way to contribute this way).
Suggesting - checking for fetch priority and loading=eager params, and if present, do not add decoding="async"
or loading="lazy."
I'm currently doing this, but it's silly to be fixing it on every site:
<?php add_filter( 'wp_content_img_tag', function( $filtered_image, $context, $attachment_id ) { // search in the filtered_image html string for loading="eager" and if present, remove decoding="async" if ( false !== strpos( $filtered_image, 'loading="eager"' ) || false !== stripos( $filtered_image, 'fetchpriority="high"' ) ) { $filtered_image = str_replace( ' decoding="async"', '', $filtered_image ); } return $filtered_image; }, 10, 3 );
Change History (4)
#2
@
15 months ago
It is possible to submit a patch via github:
https://make.wordpress.org/core/handbook/tutorials/trac/submitting-a-patch/#adding-your-github-fork-to-your-wp-trunk-copy
I forgot to mention that it has a huge impact on LCP (and can't find edit button)