// Special handling for programmatically created image tags.
if ( 'the_post_thumbnail' ===
$context || 'wp_get_attachment_image' ===
$context || 'widget_media_image' ===
$context ) { /*
* Skip programmatically created images within post content as they need to be handled together with the other
* images within the post content.
* Without this clause, they would already be considered below which skews the image count and can result in
* the first post content image being lazy-loaded or an image further down the page being marked as a high
* priority.
*/
if ( doing_filter( 'the_content'
) ) { return $loading_attrs;
} // Conditionally skip lazy-loading on images before the loop.
if ( // Only apply for main query but before the loop.
$wp_query->before_loop &&
$wp_query->
is_main_query() /*
* Any image before the loop, but after the header has started should not be lazy-loaded,
* except when the footer has already started which can happen when the current template
* does not include any loop.
*/