Needs work
Project:
Drupal core
Version:
main
Component:
media system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Jun 2019 at 08:42 UTC
Updated:
3 May 2023 at 22:08 UTC
Jump to comment: Most recent
Videos embedded in the iframes are not scaling responsively due to the hardcoded width and height iframe attributes. So even if the inside iframe scales, the outer iframe's height doesn't. Some providers (such as Vimeo) handle the inner iframe video ok (but the container iframe height still remains fixed). Others, such as Youtube, have aspect ratio issues even inside the inner iframe. That's handled in #3060968: Some oEmbed videos do not maintain aspect ratio
A solution for this is a simple js script to calculate the aspect ratio on the fly and update the height of the iframe.
Comments
Comment #2
rosinegrean commentedComment #3
phenaproximaComment #5
martijn de witThere is a contrib module that fixes this problem with an external library.
https://www.drupal.org/project/fitvids
----edit
If you want to use it, you have to add "/media/oembed?url=" as Additional video providers
Comment #7
phenaproximaComment #9
Anonymous (not verified) commentedWill this issue be fixed in D9 core?
Comment #14
rlnorthcuttActually, the solution may be even simpler than that. Instead of relying on fixed height and width settings, we can use the CSS aspect ratio property:
The parent div will also need a 100% width, but once that is set, it should be turn key. No need for JS!
Perhaps the simplest thing to do is to provide another "Format" option for the field display. We have the current "oEmbed content" format, but we could create a "oEmbed responsive" one, which allows you to set the aspect ratio (with a default of 16/9). This means existing oEmbed media will not be affected, but users can easily make the change and get the benefit of responsive videos without needing to create custom templates, custom oEmbed providers, or use extra JS.