[wp-trac] [WordPress Trac] #56588: WordPress puts "loading=lazy" on first image on archive page - wp_get_loading_attr_default bug

WordPress Trac noreply at wordpress.org
Thu Apr 27 20:34:36 UTC 2023


#56588: WordPress puts "loading=lazy" on first image on archive page -
wp_get_loading_attr_default bug
-------------------------------+--------------------------
 Reporter:  salvoaranzulla     |       Owner:  flixos90
     Type:  defect (bug)       |      Status:  assigned
 Priority:  normal             |   Milestone:  6.3
Component:  Media              |     Version:  5.9
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:  performance
-------------------------------+--------------------------

Comment (by flixos90):

 @salvoaranzulla Thank you for the additional detail, I think I have found
 the problem: WordPress core's excerpt function relies on the filter
 callback `wp_trim_excerpt()` which parses the full post content unless a
 manual excerpt text has been provided. This results in the images being
 counted when they shouldn't be.

 Can you test adding the following code to your site (e.g. in the theme's
 `functions.php`)? If I'm correct, that ''should'' function as a workaround
 for the bug until we have fixed it in WordPress core itself.


 {{{
 add_filter(
         'get_the_excerpt',
         function( $excerpt ) {
                 remove_filter( 'the_content', 'wp_filter_content_tags' );
                 return $excerpt;
         },
         9
 );
 add_filter(
         'get_the_excerpt',
         function( $excerpt ) {
                 add_filter( 'the_content', 'wp_filter_content_tags' );
                 return $excerpt;
         },
         11
 );
 }}}

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


More information about the wp-trac mailing list