[wp-trac] [WordPress Trac] #53232: Add async decoding attribute as default to the HTML image tags generated by WordPress

WordPress Trac noreply at wordpress.org
Wed Mar 30 00:16:05 UTC 2022

#53232: Add async decoding attribute as default to the HTML image tags generated by
 Reporter:  isaumya                              |       Owner:
                                                 |  adamsilverstein
     Type:  feature request                      |      Status:  assigned
 Priority:  normal                               |   Milestone:  6.0
Component:  Media                                |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  refresh                                        |  performance

Comment (by peterwilsoncc):

 [attachment:"53232.5.diff"] is [attachment:"53232.4.diff"] with a few
 minor modifications:

 * fixes the alignment of a few docblock `@param` tags
 * expands the description of `wp_img_tag_add_decoding_async_attr()`
   - generically indicates it adds the `decoding` attribute rather than the
   - expands the explanation to indicate what the attribute does, accepted
 values and how developers can modify it.

 I've also noticed that how this works is quite different to adding the
 default `lazy` tag, `lazy` includes:

 * `wp_lazy_loading_enabled()
 * `wp_get_loading_attr_default()`
 * `wp_omit_loading_attr_threshold()`

 This results in some differences in how the `decoding` attribute is added
 by default to images, particularly avatars. As these features are very
 similar in intent, it seems logical to use a similar APIs.

 I realise there was some discussion above as to whether developers
 ''ought'' to disable it but we need to account for environments in which
 they need to. For example headless environments converting WP images tags
 to their smarter defaults.

 In `wp_get_attachment_image()` the attribute ought to be added as a
 default argument to allow developers to override the value by passing an
 argument. The new argument should be added to the docblock too.

 Sorry I didn't post all this yesterday, but the `error_log()`s in the
 previous patch were early in the source and an immediate blocker.

Ticket URL: <https://core.trac.wordpress.org/ticket/53232#comment:55>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list