Changeset 55821 for trunk/src/wp-includes/media.php
- Timestamp:
- 05/17/2023 06:29:41 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r55816 r55821 1051 1051 ); 1052 1052 1053 /** 1054 * Filters the context in which wp_get_attachment_image() is used. 1055 * 1056 * @since 6.3.0 1057 * 1058 * @param string $context The context. Default 'wp_get_attachment_image'. 1059 */ 1060 $context = apply_filters( 'wp_get_attachment_image_context', 'wp_get_attachment_image' ); 1061 1053 1062 // Add `loading` attribute. 1054 if ( wp_lazy_loading_enabled( 'img', 'wp_get_attachment_image') ) {1055 $default_attr['loading'] = wp_get_loading_attr_default( 'wp_get_attachment_image');1063 if ( wp_lazy_loading_enabled( 'img', $context ) ) { 1064 $default_attr['loading'] = wp_get_loading_attr_default( $context ); 1056 1065 } 1057 1066 … … 2169 2178 function _wp_post_thumbnail_class_filter_remove( $attr ) { 2170 2179 remove_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' ); 2180 } 2181 2182 /** 2183 * Overrides the context used in {@see wp_get_attachment_image()}. Internal use only. 2184 * 2185 * Uses the {@see 'begin_fetch_post_thumbnail_html'} and {@see 'end_fetch_post_thumbnail_html'} 2186 * action hooks to dynamically add/remove itself so as to only filter post thumbnails. 2187 * 2188 * @ignore 2189 * @since 6.3.0 2190 * @access private 2191 * 2192 * @param string $context The context for rendering an attachment image. 2193 * @return string Modified context set to 'the_post_thumbnail'. 2194 */ 2195 function _wp_post_thumbnail_context_filter( $context ) { 2196 return 'the_post_thumbnail'; 2197 } 2198 2199 /** 2200 * Adds the '_wp_post_thumbnail_context_filter' callback to the 'wp_get_attachment_image_context' 2201 * filter hook. Internal use only. 2202 * 2203 * @ignore 2204 * @since 6.3.0 2205 * @access private 2206 */ 2207 function _wp_post_thumbnail_context_filter_add() { 2208 add_filter( 'wp_get_attachment_image_context', '_wp_post_thumbnail_context_filter' ); 2209 } 2210 2211 /** 2212 * Removes the '_wp_post_thumbnail_context_filter' callback from the 'wp_get_attachment_image_context' 2213 * filter hook. Internal use only. 2214 * 2215 * @ignore 2216 * @since 6.3.0 2217 * @access private 2218 */ 2219 function _wp_post_thumbnail_context_filter_remove() { 2220 remove_filter( 'wp_get_attachment_image_context', '_wp_post_thumbnail_context_filter' ); 2171 2221 } 2172 2222
Note: See TracChangeset
for help on using the changeset viewer.