[wp-trac] [WordPress Trac] #61436: 'src' not in $attr for wp_get_loading_optimization_attributes
WordPress Trac
noreply at wordpress.org
Thu Jun 13 15:31:56 UTC 2024
#61436: 'src' not in $attr for wp_get_loading_optimization_attributes
-------------------------------+-----------------------------
Reporter: prestonwordsworth | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 6.5.4
Severity: normal | Keywords:
Focuses: docs, performance |
-------------------------------+-----------------------------
The relevant [https://make.wordpress.org/core/2023/10/18/image-loading-
optimization-enhancements-in-6-4/| dev note] has the following snippet:
{{{
function set_fetchpriority_high_on_specific_image( $loading_attrs,
$tag_name, $attr, $context ) {
if ( 'img' === $tag_name ) {
if (
'the_content' === $context &&
isset( $attr['src'] ) &&
$attr['src'] === 'https://example.org/a-specific-image.jpg'
) {
$loading_attrs['fetchpriority'] = 'high';
} else {
unset( $loading_attrs['fetchpriority'] );
}
}
return $loading_attrs;
}
add_filter(
'wp_get_loading_optimization_attributes',
'set_fetchpriority_high_on_specific_image',
10,
4
);
}}}
'src', however, hasn’t made it into $attr array yet:
{{{
$optimization_attrs = wp_get_loading_optimization_attributes(
'img',
array(
'width' => $width,
'height' => $height,
'loading' => $loading_val,
'fetchpriority' => $fetchpriority_val,
'decoding' => $decoding_val,
),
$context
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61436>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list