[wp-trac] [WordPress Trac] #57086: Omit or filter decoding attribute in wp_get_attachment_image()
WordPress Trac
noreply at wordpress.org
Sun Nov 13 21:54:27 UTC 2022
#57086: Omit or filter decoding attribute in wp_get_attachment_image()
------------------------------------------+--------------------------
Reporter: maximej | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 6.2
Component: Media | Version: 6.1
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses: performance
------------------------------------------+--------------------------
Changes (by peterwilsoncc):
* keywords: => needs-patch needs-unit-tests
* focuses: => performance
* milestone: Awaiting Review => 6.2
Comment:
Hi @maximej and welcome back to trac!
The `decoding` attribute can be controlled via the
`wp_img_tag_add_decoding_attr` filter by returning a value of `false`, you
can see further
[https://developer.wordpress.org/reference/hooks/wp_img_tag_add_loading_attr/
documentation for the filter in the developer guide].
You can also control the default value by passing either `false`,
`"async"`, `"auto"` (the default value browsers use) or `"sync"` as an
attribute:
{{{#!php
<?php
echo wp_get_attachment_image( 19, 'thumbnail', false, array( 'decoding' =>
'auto' ) );
}}}
However, passing `false` displays the string as an empty attribute,
`decoding=""`, which I believe is a bug that ought to be fixed and the
attribute removed from the HTML generated.
I've moved this on to the 6.2 milestone for visibility and added the
performance focus as the bug was introduced in an earlier performance
ticket.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57086#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list