Closed (fixed)
Project:
YouTube Field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 Aug 2013 at 02:05 UTC
Updated:
29 Nov 2014 at 19:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
decipheredPatch
Comment #2
guschilds commentedThanks for the patch!
I tested it, but I'm not sure how practical it is. I'm assuming the intention is to create a responsive effect on the player. The problem is that 'height' is still accepted. When I picked 'custom' size with a width of '100%', which worked, but the pixel-based and percentage-based heights I tested didn't work in a way that made sense.
After seeing this patch, I think the best idea would be to offer 'responsive' as a size choice on the field display settings. I've dug into what it takes to make these responsive before in #22 and #27 of #1571420: Add additional YouTube player options, so I've added a bit of CSS that uses that technique to bring a new 'responsive' option to life in the attached patch.
To test the attached patch:
The video's player should responsively take up 100% of the width of it's container. If you want the player to take up less than 100% of it's parent, you can use additional CSS to apply a smaller width to any container element around the player.
I'm guessing this is an increasingly common use case these days, so I'd love to get this patch committed if it fulfills the need.
Let me know what you think!
Comment #3
guschilds commentedComment #4
decipheredPlease don't derail this issue. If you want a responsive mode, that's fine, but that doesn't discount the ability to use percentages in the height/width attributes, which is valid markup regardless of whether you personally don't see how practical it is yourself.
I would recommend that if you need more than just enabling percentage based height/width attributes that you open a secondary issue.
Comment #5
guschilds commentedI've moved the responsive stuff to #2077333: Add a responsive setting to the video display size choices.
The W3C spec for iframes specifies "...in CSS pixels" for the width and height attributes. That is why I question the practicality of accepting % values before committing the patch.
Comment #6
subhojit777I have this requirement too. Currently it does not respects percentage (like 100%) or pixel values (like 500px).
My use case:
I need width of player to be responsive and fixed height, in this case I require relative width of youtube player and absolute pixelated height.
Comment #7
guschilds commentedComment #8
subhojit777Uploading patch. Thanks to @Deciphered for the pointer. I have made minor modifications, it will not check the type of setting, the setting will be used as it is.
Comment #9
subhojit777Incorrect patch uploaded in #8. Uploading correct patch.
Comment #10
interdruper commented#9 works. Now a custom size mixing % and pixels is allowed, like width="100%" and height="480px".
Note that in some browsers the combination width="100%" and height="100%" or height="auto" does not work properly, so a fixed height is required.
Comment #12
guschilds commentedThe patch in #9 was not committed because:
auto"></iframe><script>alert('hey!');</script><iframeas a dimension and load a page with a video player.px" is never needed and "auto" isn't valid.My statement in #5 about pixels only was only correct for HTML5. I've committed the original patch to the 7.x-1.x branch and percentage-based values are now properly applied when using custom player dimensions.
Thanks for the patches, testing, and patience everyone.