-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Try: Fix embed iframe sizing issue. #40213
Conversation
Size Change: -5 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
Hey, I've tested this with the pinterest embed and a few others (youtube, loom). Also with the HTML block (preview), the other use of the sandbox component I could find. It works fine:
The last change I saw was #26842 (Nov 2020) and the reason for it was the loom block. Not sure if some host-specific setup. I've tested that block and it still works as expected with this change (because it gets attached the aspect ratio class). I then tried to change to a theme that doesn't support responsive embeds to see how this fared. Used TwentyTwentyOne and removed support in its The logic seems fine, but I reckon I haven't been involved in this problem space, so may miss something. Do you think I should test any other thing? |
Thank you for testing, I appreciate that. In general testing the embeds, thanks for also testing Loom and pointing out that PR! Perhaps @retrofox can chime in and see if there's any context I might be missing? Overall I think this one should be fairly safe to land since it's mainly a CSS change that makes the editor look the same as the frontend. |
width: 100%; | ||
} | ||
html.wp-has-aspect-ratio, | ||
body.wp-has-aspect-ratio, | ||
body.wp-has-aspect-ratio > div, | ||
body.wp-has-aspect-ratio > div iframe { | ||
width: 100%; |
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.
It seems that wp-has-aspect-ratio
class is added from embed
block. Not added here of course, but should the related styles live in that block? 🤔
We are making a change here that affects an exposed component(Sandbox
) and I'm not 100% sure that the style removed above couldn't affect some existing usages from third party plugins, etc..
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.
Good point. What's the best way forward, you think?
I'll try to take a look, Joen. |
Thank you! Please note Nik's comment here, #40213 (comment) — and if you'd like to push directly to this branch, feel free. |
7ed4943
to
9d97a8b
Compare
I've rebased this one just to keep it current. It still solves the issue in question, and it's such a small bugfix, I'd love to land it. CC: @WordPress/gutenberg |
Thank you. I'm going to land this because it's such a small change that's easy to revert if there are unintended consequences. |
What?
Pinterest embeds are broken in the block editor, they appear cropped:
This happens because we have a rule that sets the iframe to be 100% wide inside, regardless of what original dimensions are set. This is fine for when the responsive embedding property is set so it can scale to an aspect ratio, but from what I can tell in the code, we apply this rule regardless of that.
This PR moves the width rule to only apply when responsive embed classes are present. Which appears to have changed recently, so I could use a sanity check both on the code and the assumed behavior.
Nevertheless, this PR fixes the issue in the process:
Perhaps most importantly, this makes it match the frontend:
Right now in trunk, the edit view doesn't match the frontend at all. That feels like a baseline to restore.
Testing Instructions
Paste a Pinterest embed such as
https://www.pinterest.com/pin/1023865296507001702/
in the editor, and it should not be cropped and look the same on the frontend.