Make WordPress Core


Ignore:
Timestamp:
04/08/2020 12:53:18 AM (5 years ago)
Author:
azaozz
Message:

Media: Enable lazy-loading of images by automatically adding the new loading="lazy" attribute to image tags on the front-end.

  • Introduces wp_lazy_loading_enabled(), wp_filter_content_tags(), wp_img_tag_add_loading_attr(), and wp_img_tag_add_srcset_and_sizes_attr() functions.
  • Introduces wp_lazy_loading_enabled, wp_img_tag_add_loading_attr, and wp_img_tag_add_srcset_and_sizes_attr filters.

Props flixos90, addyosmani, mor10, swissspidy, pierlo, westonruter, spacedmonkey, mikeschroder, jonoaldersonwp, peterwilsoncc, narwen, jeffpaul, OptimizingMatters, futtta, mukeshpanchal27, azaozz.

Fixes #44427.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r47455 r47554  
    176176add_filter( 'the_content', 'shortcode_unautop' );
    177177add_filter( 'the_content', 'prepend_attachment' );
    178 add_filter( 'the_content', 'wp_make_content_images_responsive' );
     178add_filter( 'the_content', 'wp_filter_content_tags' );
    179179
    180180add_filter( 'the_excerpt', 'wptexturize' );
     
    183183add_filter( 'the_excerpt', 'wpautop' );
    184184add_filter( 'the_excerpt', 'shortcode_unautop' );
     185add_filter( 'the_excerpt', 'wp_filter_content_tags' );
    185186add_filter( 'get_the_excerpt', 'wp_trim_excerpt', 10, 2 );
    186187
     
    208209add_filter( 'widget_text_content', 'wpautop' );
    209210add_filter( 'widget_text_content', 'shortcode_unautop' );
     211add_filter( 'widget_text_content', 'wp_filter_content_tags' );
    210212add_filter( 'widget_text_content', 'do_shortcode', 11 ); // Runs after wpautop(); note that $post global will be null when shortcodes run.
    211213
Note: See TracChangeset for help on using the changeset viewer.