[wp-trac] [WordPress Trac] #58853: Fix shortcode output not receiving image (and other) optimizations

WordPress Trac noreply at wordpress.org
Wed Jul 19 17:09:04 UTC 2023


#58853: Fix shortcode output not receiving image (and other) optimizations
-------------------------+-------------------------------------------------
 Reporter:  flixos90     |      Owner:  flixos90
     Type:  defect       |     Status:  assigned
  (bug)                  |
 Priority:  normal       |  Milestone:  6.4
Component:  Media        |    Version:  5.5
 Severity:  normal       |   Keywords:  2nd-opinion needs-patch needs-unit-
  Focuses:  performance  |  tests
-------------------------+-------------------------------------------------
 This ticket aims to properly address the bug that was discovered and
 initially discussed in #58681, starting
 [https://core.trac.wordpress.org/ticket/58681#comment:13 with this
 comment]: As of today, HTML from shortcodes does not receive the
 optimizations from `wp_filter_content_tags()` like other content does.
 This has been due to an unfortunate oversight from when the function was
 initially introduced in WordPress 5.5, as it used the default hook
 priority of 10 on the `the_content` filter, while `do_shortcode` uses hook
 priority 11.

 Similarly, when `wp_filter_content_tags()` was used in other places like
 parsing of block templates or block template parts, it was also
 implemented in the same incorrect order.

 #58681 implemented a hacky workaround to at least get the loading
 optimization attributes from `wp_get_loading_optimization_attributes()`
 added to shortcodes, yet even that workaround does not work reliably since
 images using it are parsed separately from the rest of the content, which
 can lead to LCP problems, e.g. when a shortcode is on top of the page, as
 it would still receive `loading="lazy"` when it shouldn't.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58853>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list