我已经通过以下链接
-> Removing black borders 4:3 on youtube thumbnails
-> How to remove black border of Youtube image
我们的项目中有很多尺寸(宽度和高度)不同的视频。
尝试以下解决方案
解决方案1 :裁剪或调整高度
Expression<Func<TUser, bool>> filter = t => string.IsNullOrWhiteSpace(tenantId) ? t.TenantId != null : t.TenantId == tenantId;
Image with less black border Image with more black border
解决方案2 :将其用作背景图像,将其居中并更改高度。
HTML
<div class="thumb">
<img src="...">
</div>
CSS
.thumb {
overflow: hidden;
}
.thumb img {
margin: -10% 0;
width: 100%;
}
Failing for some sceanrios , because of image black border size is varying for few images.
Screenshot for reference
解决方案3:获取不带有黑色边框的Youtube图像(使用mqdefault.jpg而不是0.jpg)
关注此链接How do I get a YouTube video thumbnail from the YouTube API?
基于以上链接,我们知道mqdefault.jpg图像没有黑色边框
.youtubePreview {
background:url('http://img.youtube.com/vi/aOPGepdbfpo/0.jpg') center no-repeat;
height:204px;
width:480px;
}
or
also tried with background-image
<div class="bgimg" style="background-image: url("https://img.youtube.com/vi/8yxZ-k0xI9s/0.jpg"); height:275px "></div>
Example: 450*275 failing
We have video with different sizes so it works for some width and its failing for other widths.
任何人都可以提出一些想法来实现这一目标吗?
预先感谢
答案 0 :(得分:0)
以下是我改编的一些示例(通过检查嵌入视频并查看其CSS样式):
示例1:
.ytp-cued-thumbnail-overlay-image {
background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;
background-position: center;
background-repeat: no-repeat;
width: 100%;
height: 100%;
position: absolute;
}
<p>Image 1: </p>
<div class="ytp-cued-thumbnail-overlay-image" style="background-image: url('https://i.ytimg.com/vi/3TJgmUGFHqw/sddefault.jpg');"></div>
示例2:
.ytp-cued-thumbnail-overlay-image {
background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;
background-position: center;
background-repeat: no-repeat;
width: 100%;
height: 100%;
position: absolute;
}
<p>Image 2: </p>
<div class="ytp-cued-thumbnail-overlay-image" style="background-image: url('https://i.ytimg.com/vi/NNgYId7b4j0/maxresdefault.jpg');"></div>