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.
I'm displaying the embedded video with a custom node view, as thumbnail with colorbox popup. The preview image has black bars on the top and bottom. I'd like to display the hires image - is that possible?
For example, on the youtube page, the first video in the uploads section at https://www.youtube.com/user/TrevorThePetGuy
has a preview image of https://i.ytimg.com/vi/YQB8i4XjfX8/mqdefault.jpg
Comment | File | Size | Author |
---|---|---|---|
#7 | 2607790--video_embed_field-7x--default-to-youtube-max-resolution-thumbnail.patch | 495 bytes | ndf |
Comments
Comment #2
acrosmanThe black bars are likely generated by the image style being used having a different aspect ration than the YouTube provided thumbnail. See: http://drupal.stackexchange.com/questions/21308/change-image-background-... for suggestions on how to fix the style definition to control the background. Alternatively, change the aspect ratio so it matches the source images from YouTube.
Comment #3
HannahMR CreditAttribution: HannahMR commentedI've tried many different image styles to attempt to match YouTube's aspect ratio, but nothing seems to have any effect.
Has anyone found another solution to this issue?
Comment #4
Sam152 CreditAttribution: Sam152 at PreviousNext commentedMy research for the 8.x branch is relevant to this issue: #2711323: YouTube videos have black bars..
Comment #5
Volkie CreditAttribution: Volkie commentedHi
I used the following solution to create an embedded youtube video without black bars on my drupal page (Open Outreach), inside a block, aligned with the rest of the block.
//In the block body:
//In the CSS:
.container {
position: relative;
padding-bottom: 56,25%;
height: 0;
}
.video {
position: absolute;
left: -5px;
margin-top: 0px;
width: 105%;
height: 105%;
}
For me this works like a charm!
Comment #6
ndf CreditAttribution: ndf at Dx Experts commentedComment #7
ndf CreditAttribution: ndf at Dx Experts for Triquanta commentedSo I was xdebugging through the 7.x branch and inside
video_embed_field_field_presave()
the actual thumbnail is downloaded.This makes it difficult/impossible without refactoring of the branch to make use of the fallback as in the 8.x branch commit (http://cgit.drupalcode.org/video_embed_field/commit/?id=4c01b41).
It might be easier to add an configuration option to the field that let the site-builder choose which thumnail-type to choose.
But my proposal would be to just default to
maxresdefault
. It looks a lot better.The attached patched does just that.
There is an upgrade issues, because the old thumbnail are still in the system and they are not recreated automatically.
I can trigger recreation by:
1. Delete the old files in /files/video_embed_field_thumbnails/youtube
2. Re-save any node has a video_embed_field with youtube video
Comment #8
ndf CreditAttribution: ndf at Dx Experts for Triquanta commentedAnd I tried to create an update function. But not successful though.
The manual procedure in #7 works.
This is a start for the hook_update.
It will call
entity_save()
for all entities with avideo_embed_field
.But that does not trigger the required call to
video_embed_field_field_presave()
Don't know why.
But even if it would work; for a site with a lot of thumbnails this easily can trigger time-outs.
So maybe it is better to put this issue to "no-fix" and keep the patch #7 waiting here.
Note that for a Drupal 7 site without existing thumbnails you can use the patch in #7 without any issues.
Comment #9
Ahmad Abbad CreditAttribution: Ahmad Abbad at Vardot commentedI fix it by create new views with bulk operation and 'Publish content' for all content you need to generate new thumbnail.
Comment #10
mjk200 CreditAttribution: mjk200 commentedYou can use online service like (https://www.youtubethumbnaildownloaderonline.com/?id=YQB8i4XjfX8) to get the preview image of your choice