[wp-trac] [WordPress Trac] #44470: meta property=“og:image” doesn't register if an image is executed via a shortcode in WP Post and Pages
WordPress Trac
noreply at wordpress.org
Wed Jul 2 15:05:03 UTC 2025
#44470: meta property=“og:image” doesn't register if an image is executed via a
shortcode in WP Post and Pages
--------------------------------------+------------------------------
Reporter: nlstm | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 4.9.6
Severity: critical | Resolution: wontfix
Keywords: dev-feedback needs-patch | Focuses:
--------------------------------------+------------------------------
Changes (by callumbw95):
* status: reopened => closed
* resolution: => wontfix
Comment:
Hi All,
Just taking a look at this ticket now, as its been sitting for a while.
The core of the problem lies in the WordPress loading sequence. The <head>
of the document is processed and output before the_content is rendered,
which is when shortcodes are parsed and executed. To make og:image aware
of images inside shortcodes, we would need to parse the_content
prematurely.
As discussed extensively here and in related tickets, pre-processing
the_content just to scan for images has significant performance
implications and can lead to a host of problems:
Performance: It can be very resource-intensive, effectively requiring the
post content to be processed twice.
Inaccuracy: Shortcodes can be complex and may not reliably produce the
same output every time. A simple regex or pre-scan might not accurately
determine the final image URL.
Unintended Side Effects: Executing do_shortcode early could trigger other
hooks or functions prematurely, leading to unpredictable behavior and
breaking plugins that rely on the standard execution order.
The established and correct way to handle this is at the plugin or theme
level. SEO plugins, which are best suited for managing Open Graph tags,
often provide their own solutions for this. They can either offer a
specific field to set the og:image manually or implement their own content
parsing logic, which is the appropriate place for such functionality. For
developers, the recommended approach is to use a dedicated filter or
function from an SEO plugin, or to manually specify the desired image in a
custom field that is then used to populate the og:image tag.
Given that fixing this in Core would require a fundamental and high-risk
change to the WordPress rendering lifecycle, and because robust solutions
already exist in the plugin ecosystem where this functionality is best
managed, this isn't something we can or should address in Core itself.
For these reasons, I am closing this ticket as `wontfix`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44470#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list