I have tried to use code mentioned in dev note but it is not working, this is the snippet I have tried:
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
);
I am not to add fetchpriority
high by comparing the url
of the image
in WordPress using the hook.