- First commit to issue fork.
- π¬π§United Kingdom malcomio
There are CSS-only ways to achieve this, which I would prefer to a JS approach.
See https://www.benmarshall.me/responsive-iframes/ and https://css-tricks.com/responsive-iframes/
So I'd suggest we either:
1. Use the existing width and height fields, and if the user enters a unitless value, use that as the aspect ratio, rather than assuming they mean px
2. Add an extra field to control the aspect ratioOption 1 feels cleaner to me, but we would need to consider backwards compatibility - perhaps an update hook to convert existing unitless values to px values?
- Merge request !11Issue #3285175: Support responsive iframes that maintain aspect ratio β (Closed) created by malcomio
- πͺπ¨Ecuador jwilson3
Thanks for picking this up @malcomio. In order to pull arbitrary aspect ratios from width/height, according to the docs you linked to, we would need to use the var(--aspect-ratio) solution to pass the local value from the iframe's inline style attribute into some standard CSS shipped with the module. This feels a bit hacky.
At the same time, I just found something from the author of the gist I pointed to above:
to be completely honest, I would probably just use CSS's new
aspect-ratio
to do this nowadays. Avoid thepadding-bottom
hack.I was unaware of aspect-ratio until today, but this does seem to be like a better approach, and could be implemented in an inline style attribute, without the need of passing var(--aspect-ratio) dynamic css variable around.
Support seems pretty stable at this point:
https://caniuse.com/mdn-css_properties_aspect-ratioThoughts?
- Status changed to Needs review
over 1 year ago 5:33am 6 April 2023 - π¬π§United Kingdom malcomio
Merge request !11 should now be ready to review, although it does not include any update hook to convert existing values.
- First commit to issue fork.
-
malcomio β
authored a76f57d0 on 8.x-2.x
Issue #3285175 by malcomio: Support responsive iframes that maintain...
-
malcomio β
authored a76f57d0 on 8.x-2.x
- πΊπΈUnited States smustgrave
Should this be closed as something was committed?
- Status changed to RTBC
7 months ago 4:13pm 28 May 2024 - Status changed to Fixed
4 months ago 4:43pm 18 August 2024 Automatically closed - issue fixed for 2 weeks with no activity.