You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Image previews are not displayed in the sidebar of image blocks in a WordPress 7.0 + wp-env environment. #76476
@adamsilverstein@andrewserong, I understand that all external resources in the document are being checked, but is there any way to avoid this issue?
Good question. Adam might have a better insight here than I do as I'm not 100% sure what our limitations are here, but it seems that this is really down to the CORS policy of the linked image. I.e. if I grab this one from the wordpress.org website, it displays fine:
And it has the following response header:
Whereas for the image in the issue description, I get this and a CORS error:
I think that might have been why we didn't catch it earlier!
So, a question (likely for @adamsilverstein) — now that we're using the Document-Isolation-Policy as of #75991, would it be safe to remove mutating the img elements so that we can avoid adding crossorigin="anonymous"?
An alternative, if we do still need that, might be to update the img elements used in media controls like this to fallback to a placeholder image if they're unable to load 🤔
now that we're using the Document-Isolation-Policy as of #75991, would it be safe to remove mutating the img elements so that we can avoid adding crossorigin="anonymous"?
Just to try to inch toward a fix, I've opened up a PR to try this out in #76618. I'm very much not sure if this is the right approach, but figured it'd be worth trying it out.
Happy to close it out if there's a better way to go about this!
So, a question (likely for @adamsilverstein) — now that we're using the Document-Isolation-Policy as of #75991, would it be safe to remove mutating the img elements so that we can avoid adding crossorigin="anonymous"?
Yes, that seems right. This is no longer needed for img tags and should have been removed when we added DIP. PR looks good to me.
Activity
t-hamano commentedon Mar 13, 2026
I believe the reason is that
crossorigin=anonymousis applied via theaddCrossOriginAttributefunction:@adamsilverstein @andrewserong, I understand that all external resources in the document are being checked, but is there any way to avoid this issue?
andrewserong commentedon Mar 16, 2026
Good question. Adam might have a better insight here than I do as I'm not 100% sure what our limitations are here, but it seems that this is really down to the CORS policy of the linked image. I.e. if I grab this one from the wordpress.org website, it displays fine:
And it has the following response header:
Whereas for the image in the issue description, I get this and a CORS error:
I think that might have been why we didn't catch it earlier!
So, a question (likely for @adamsilverstein) — now that we're using the
Document-Isolation-Policyas of #75991, would it be safe to remove mutating theimgelements so that we can avoid addingcrossorigin="anonymous"?An alternative, if we do still need that, might be to update the
imgelements used in media controls like this to fallback to a placeholder image if they're unable to load 🤔andrewserong commentedon Mar 18, 2026
Just to try to inch toward a fix, I've opened up a PR to try this out in #76618. I'm very much not sure if this is the right approach, but figured it'd be worth trying it out.
Happy to close it out if there's a better way to go about this!
andrewserong commentedon Mar 18, 2026
Just unassigning myself from this one — I'll be AFK after tomorrow so might not be around to see a fix through.
adamsilverstein commentedon Mar 18, 2026
Thanks for the bug report and initial investigation, I am taking another look now.
adamsilverstein commentedon Mar 18, 2026
@inc2734 can you confirm if Andrew's PR fixes your issue?
adamsilverstein commentedon Mar 18, 2026
Yes, that seems right. This is no longer needed for img tags and should have been removed when we added DIP. PR looks good to me.
adamsilverstein commentedon Mar 18, 2026
I created a core backport PR for this change: WordPress/wordpress-develop#11291
andrewserong commentedon Mar 18, 2026
Thanks Adam! I've merged the Gutenberg PR, so I'll give the backport PR a look now.
Media: Remove `IMG` from crossorigin attribute injection.
adamsilverstein commentedon Mar 19, 2026
I committed the backport PR (Pascal had approved), hope it looks good to you!
Media: Remove `IMG` from crossorigin attribute injection.
andrewserong commentedon Mar 19, 2026
It did! 🙂