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/deprecated.php

    r47198 r47554  
    25102510 *
    25112511 * Use global $plugin_page and/or get_plugin_page_hookname() hooks.
    2512  * 
     2512 *
    25132513 * For more information on this and similar theme functions, check out
    2514  * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 
     2514 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
    25152515 * Conditional Tags} article in the Theme Developer Handbook.
    2516  * 
     2516 *
    25172517 * @since 1.5.0
    25182518 * @deprecated 3.1.0
     
    37173717/**
    37183718 * Determines whether the current URL is within the comments popup window.
    3719  * 
     3719 *
    37203720 * For more information on this and similar theme functions, check out
    3721  * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 
     3721 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
    37223722 * Conditional Tags} article in the Theme Developer Handbook.
    3723  * 
     3723 *
    37243724 * @since 1.5.0
    37253725 * @deprecated 4.5.0
     
    39513951    }
    39523952}
     3953
     3954/**
     3955 * Filters 'img' elements in post content to add 'srcset' and 'sizes' attributes.
     3956 *
     3957 * @since 4.4.0
     3958 * @deprecated 5.5.0
     3959 *
     3960 * @see wp_image_add_srcset_and_sizes()
     3961 *
     3962 * @param string $content The raw post content to be filtered.
     3963 * @return string Converted content with 'srcset' and 'sizes' attributes added to images.
     3964 */
     3965function wp_make_content_images_responsive( $content ) {
     3966    _deprecated_function( __FUNCTION__, '5.5.0', 'wp_filter_content_tags()' );
     3967
     3968    // This will also add the `loading` attribute to `img` tags, if enabled.
     3969    return wp_filter_content_tags( $content );
     3970}
Note: See TracChangeset for help on using the changeset viewer.