Removing black borders 4:3 on youtube thumbnails

后端 未结 7 679
暗喜
暗喜 2020-12-01 05:20

E.g. I have a link

http://img.youtube.com/vi/aOPGepdbfpo/0.jpg

for a youtube video thumbnail:

相关标签:
7条回答
  • 2020-12-01 05:30

    Use it as a background image, center it and change height.

    http://dabblet.com/gist/4012604

    .youtubePreview {
        background:url('http://img.youtube.com/vi/aOPGepdbfpo/0.jpg') center no-repeat;
        height:204px;
        width:480px;
    }
    
    0 讨论(0)
  • 2020-12-01 05:32

    To remove the black borders from the Youtube thumbnail we need not have to write a seperate code or CSS. Simply use the ytimg.com site, that stands for YouTube image, which fetches the images from YouTube, like thumbnails and icons as required which come from that domain.

    Example shown below -

    Original Image [With borders]

    http://img.youtube.com/vi/JQ7a_8psCn0/hqdefault.jpg

    With No borders/Strips

    1. http://img.youtube.com/vi/JQ7a_8psCn0/mqdefault.jpg

    OR

    1. http://i.ytimg.com/vi/JQ7a_8psCn0/mqdefault.jpg
    0 讨论(0)
  • 2020-12-01 05:32

    This is answer I gave for similar question, but it will solve your problem completely, just cut everything you don't want to be shown from the video with the wrapper div, this is done with html and css.

    After searching the net a while for fix of this issue I came up with nothing, I think I have tried everything and nothing solved my problem. Then driven by my logic I just wrapped the iframe of the embedded youtube video in one div set overflow: hidden; to this div and made it's height 2px smaller then the iframe height (on my video there was black border in the bottom). So the wrapper div is smaller then the iframe and with positioning it over the video you can hide the black borders you don't want. I think that this is the best solution from everything I have tried so far.

    From this example below try embedding just the iframe and you will see small black border at the bottom, and when you wrap the iframe in the div the border is gone, because the div is overlapping the iframe and it's smaller then the video, and it has overflow: hidden so everything that goes out of the div dimensions is hidden.

    <div id="video_cont" style="width: 560px;
                                height: 313px;
                                overflow: hidden;">
    
    
        <iframe id="the-video" class="extplayer" width="560" height="315" src="https://www.youtube.com/embed/EErx017kDHQ?&amp;autoplay=0&amp;rel=0&amp;fs=0&amp;showinfo=0&amp;controls=0&amp;hd=1&amp;wmode=transparent&amp;version=2;yt:quality=high;"   frameborder="0" allowfullscreen></iframe>
    
    </div>
    

    In my case the border was with about 2px height so I made the wrapper div 2px smaller in height to hide the border, in your scenario if the border is on the top of the video or on the sides and/or with different dimensions, you have to make different dimensions for the wrapper div and position it good so it overlaps the video where the borders are and with overflow:hidden; the borders are hidden.

    Hope this will help.

    0 讨论(0)
  • 2020-12-01 05:36

    How youtube do it. There's lot of parameter in the image url.

    https://i.ytimg.com/vi/XkOpbLBzPsY/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=Gv-oyTIgA39e7UG01pZ2RiGbwSo
    
    0 讨论(0)
  • 2020-12-01 05:39

    YouTube offers images that don't have the 4:3 ratio black strips. To get a 16:9 video thumbnail with no black strips, try one of these:

    http://img.youtube.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
    http://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
    

    The first one mqdefault comes as a 320x180 pixel image.

    The second one maxresdefault comes as a 1500x900 pixel image, so it would need resizing to use as a thumbnail. This is a nice image but it isn't always available. If the video is of a low quality (less than 720p I'd imagine, not exactly sure) then this 'maxresdefault' becomes unavailable. So never rely on it.

    0 讨论(0)
  • 2020-12-01 05:40

    If you want it with a flexible width, use this:

    HTML

    <div class="thumb">
        <img src="...">
    </div>
    

    CSS

    .thumb {
        overflow: hidden;
    }
    .thumb img {
        margin: -10% 0;
        width: 100%;
    }
    
    0 讨论(0)
提交回复
热议问题