Problem/Motivation
There is an issue with FitVids not applying to some videos embedded with oEmbed. When a video is embedded with oEmbed, the <iframe>'s src is /media/oembed/?url=https...., and the current logic in fitvids.module that handles custom vendors sets the selector to look for src URLs starting with the specified values, rather than looking for them in any part of the URL: iframe[src^="' . trim($value) . '"]'.
As a result, since the src of oEmbed embedded videos start with /media/oembed, custom vendors specified do not get FitVids applied.
On a separate, but semi-related note, YouTube videos embedded with oEmbed get their URL converted from youtube.com to youtu.be, so adding youtu.be as a custom vendor should apply to those videos after this issue is resolved.
Proposed resolution
In fitvids.module, update the custom vendor selector to search for <iframe>s matching the custom vendors in any part of the URL, rather than limited it to just those that begin with it, which will allow oEmbed videos to have FitVids applied.
Additionally, the selectors for the default providers in jquery.fitvids.js already use iframe[src*= instead of iframe[src^= to search for iframes matching any part of the src URL, so this will keep it consistent.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | fitvids-fix-oembed-issue-3158833-21.patch | 544 bytes | sundhar |
| #12 | fitvids-vimeo.png | 271.63 KB | mrpauldriver |
| #2 | fitvids-fix-oembed-issue-3158833-2.patch | 1.72 KB | edwardchiapet |
Issue fork fitvids-3158833
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
edwardchiapetThis patch should resolve the issue.
Comment #3
socialnicheguru commentedComment #4
loze commentedPatch works. thanks.
Comment #5
abaier commentedThanks for the patch – this also works for us. Setting this RTBC
Comment #6
mstrelan commentedEdge case to consider, you enter "youtube.com" and someone embeds a video from "totallynotyoutube.com" this is now subject to fitvid.js processing.
Comment #7
chegor commented+1 RTBC
Comment #8
edwardchiapetComment #9
edwardchiapetComment #10
mrpauldriver commentedI have not tested this, but in light of the comments regarding alternative YouTube domains, does this work with youtube-nocookie.com ?
Comment #11
mrpauldriver commentedPatch does not work for Vimeo.
Comment #12
mrpauldriver commentedVimeo
The video scales down responsively, but the parent oembed iframe does not scale with it.
Please see screenshot.
Probably related issue
#3060968: Some oEmbed videos do not maintain aspect ratio
Comment #13
mrpauldriver commentedI have found that by using the css below in my theme, I can manage without Fitvids completely and the problem with Vimeo is also resolved.
The padding-top value may cause a problem where videos arrive at different aspect ratios, but I think this would fix most situations.
Comment #14
zebda commented#13 seems to work, only thing is that the css class should be:
.field-name-field-media-oembed-videoComment #15
caspervoogt commentedThe patch works, as does that CSS from #13. I think it's useful and appropriate for the module to support oembed iframes, without the need for custom CSS, even though the CSS from #13 works fine. RTBC
Comment #16
nickdickinsonwildePatch solution seems default good. However... that would be a breaking change. I would support this if it was behind a settings flag for existing sites.
Comment #17
caspervoogt commented@MrPaulDriver thanks for that CSS, that helps.
Comment #18
imclean commentedI'm not sure this patch is necessary. Add the oembed URL (e.g.
https://www.example.com/media/oembed) to "Additional video providers" to get fitvids to recognise it.Comment #19
imclean commentedI'm also using this patch #2966656-34: Negotiate max width/height of oEmbed assets more intelligently.
Comment #21
sundhar#2 Patch Re-roll
Comment #22
sundharPatch file renamed.
Comment #23
sundharComment #25
qpro#18 works for me, thanks, it save my day, although it's a workaround that could lead to some problems because of the absolute path, for example when changing between environments with diferent domain (dev.example.com/beta.example.com/example.com)
Comment #26
imclean commented@qpro, just add the URLs for all the environments, the field accepts multiple values.