-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iframed editor: Fix relative wp-content URLs #66751
base: trunk
Are you sure you want to change the base?
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @tambourine-man, @Pat-Relentless, @nicolasleroy. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +24 B (0%) Total Size: 1.82 MB
ℹ️ View Unchanged
|
@@ -272,6 +272,7 @@ function Iframe( { | |||
<html> | |||
<head> | |||
<meta charset="utf-8"> | |||
<base href="${ window.location.origin }"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work, regardless of how the site is configured (top level, sub folder, ...) and also for third-party block editors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't matter for relative urls starting with /
, they should always use the root.
But for relative urls that don't start with a slash it's trickier. We'd have always use the current post URL etc. This wouldn't work without an iframe either (in the admin), so not sure if it's worth fixing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
Btw I just tested this manually setting an image block's URL. |
What?
Adds a
<base>
element to the iframed editor to work with relative URLs.Fixes #54262
Rebase of #56533
Why?
Currently the editor in the iframe does not work with relative URLs.
Relative URLs work in the editor without iframe, where the media are loaded relative to the admin URL. The element restores the old behavior. In further iterations, we can make the editor even more flexible so that it can also work with other URLs.
Testing Instructions