Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is there any chance to make a video adaptive? Because when I resize the size of the window now - the size of the video stays same.
Thank you!
Comments
Comment #2
minnur CreditAttribution: minnur at Chapter Three commentedHello,
You should be able to do so by applying width and height in CSS.
Example here: https://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php
See also: #1927318: CSS DIV class around the embedded Video
Thanks
Comment #3
leramulina CreditAttribution: leramulina commentedminnur It is not working at all. The size of the iframe is not changing.
Comment #4
minnur CreditAttribution: minnur at Chapter Three commented@leramulina I just tried to add width: 100% and height auto via Developer tools and it worked. Not sure how you're trying to implement this. Some code example would be helpful.
Comment #5
leramulina CreditAttribution: leramulina commentedI added this
.media-youtube-video {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
}
.media-youtube-video iframe,
.media-youtube-video object,
.media-youtube-video embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
And now everything works 100%!!!
Comment #6
minnur CreditAttribution: minnur at Chapter Three commentedHi @leramulina glad you were able to fix this. I am closing this ticket.
Thanks!
Comment #7
Liliplanet CreditAttribution: Liliplanet as a volunteer commentedHi! I've tried leramulina's css, to no avail.
Then also tried the following in my bootstrap theme css:
also tried ..
.. still no happiness. Would you be so kind to point us in the right direction on how to get the video to play as adaptive on different devices?
Most appreciated :)
Comment #8
Liliplanet CreditAttribution: Liliplanet as a volunteer commentedComment #9
safetypinI've used that technique many times successfully, but percentages provided in that tutorial never work for me. I'm not sure why.
However, the css code is dependent upon the aspect-ratio of the video being embedded. So, theoretically, it should be possible to include all of the CSS except for the "padding-bottom" line in a CSS file with the module, and then embed an inline css in the containing div with just that one line. It would be necessary to extract the height/width from the token, with a fallback of using the configuration options set in the input filter. While I can't really imagine someone wanting their video to not be responsive, it seems prudent to me to add an option to include the extra CSS.
@Liliplanet, it's too complicated for me to troubleshoot without being able to inspect the HTML and CSS. If you can give a link to where you have your code running, I'll look at it and see if I can figure out why it's not working.
Comment #10
fdverwoerd CreditAttribution: fdverwoerd at Dutch Open Projects commentedOne thing that happens in a Wysiwyg is the removal of the
<div class="video-filter">
because of limited html element rules.I really don't want to give people access to DIV, so I rewrote template to use span, and I styled the class
.video-filter
asdisplay: block
Comment #11
millionleaves CreditAttribution: millionleaves as a volunteer and commentedI used this code in my site to display YouTube videos at 100% of the available space - so the video scales down as the space available shrinks:
if the video-filter class is being stripped by your WYSIWYG configuration, you could edit the text format, although in my site (based on Opigno) there is a Video Filter setting in the Text Filter options - with that enabled, the video-filter class is left in place.