[wp-trac] [WordPress Trac] #58853: Fix shortcode output not receiving image (and other) optimizations
WordPress Trac
noreply at wordpress.org
Tue Aug 1 20:19:50 UTC 2023
#58853: Fix shortcode output not receiving image (and other) optimizations
-------------------------------------------------+-------------------------
Reporter: flixos90 | Owner: flixos90
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.4
Component: Media | Version: 5.5
Severity: normal | Resolution:
Keywords: 2nd-opinion needs-patch needs-unit- | Focuses:
tests | performance
-------------------------------------------------+-------------------------
Comment (by flixos90):
Replying to [comment:6 joemcgill]:
> For example, if a page included a large image block followed by a
shortcode generated image (in my previous example), we would want to
ensure that `fetchpriority="high"` was added to the image block and not
the shortcode generated image.
>
> Currently, I suspect the shortcode generated image would actually be the
one that receives the `fetchpriority` attribute.
Since blocks are parsed before the `wp_filter_content_tags()`, and the
`wp_get_attachment_image` context that images in blocks would typically be
using is explicitly not treated during `the_content` filter, so the block
would work as expected I think. The problem is that the shortcode would
currently be parsed after `wp_filter_content_tags()`, which realistically
for this example would not cause any functional problem because it would
happen after the block image anyway.
It's actually the reverse example I think which would be broken right now:
A large shortcode generated image followed by a large image block would
currently result in the 2nd image receiving `fetchpriority="high"` because
only that image would be handled as part of `wp_filter_content_tags()`.
That's because the shortcode is parsed later than that, i.e. too late.
By parsing shortcodes before `wp_filter_content_tags()` ''and'' ensuring
that images from the `do_shortcode` context are ignored during
`the_content` filter, it should be ensured that both kinds of images are
handled only within `wp_filter_content_tags()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58853#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list