YouTube embeds were improved a while ago by removing the black bars if they were present.
However these persist in Thumbnails of many videos. Can this be addressed too?
YouTube embeds were improved a while ago by removing the black bars if they were present.
However these persist in Thumbnails of many videos. Can this be addressed too?
The particualr change about the back bars came down to using the maxresdefault
image instead of the hqdefault
. Not all videos have a high res thumbnail though, so in those cases, we fallback to the opengraph image, which is equivalent to hqdefault
.
That image size has a different aspect ratio and includes black bars. But in both cases, we have the aspect ratio fixed to 16:9, so the black bars should not be visible when displaying the player.
Hereās an example of one video that does not have a high res image and itās using this one for the thumbnail.
Can you share some examples where this is happening?
Sure, thanks for your interest.
Hereās a couple of videos that now look great in the embed, but show black bars when thumbnailed (and in preview):
og:image is:
as you rightly point out ā¦ has black bars.
And
og:image is:
as you rightly point out ā¦ has black bars ā¦
NB Here is a āgood caseā:
og:image in this case is much bigger:
ā¦ but an automated way of doing this in core would be great as this is super annoying to have to keep doing semi-manually.
The challenge is identifying which images can be cropped?
Is it just a case of forcing 16:9 if you discover the youtube image is 4x3 or below a certain res (which means it must have black bars?).
I guess that might mean optimize image being passed a flag to tell it itās dealing with youtube?
Seems strange to me that YouTube doesnāt standardise to 16:9 thumbnails?! Perhaps Iām missing something ā¦
Thanks for enlightening me on the size difference!
I think I understand what you mean now, but processing images on core does not really fit with our use case for them. We donāt store the thumbnails for these embeds, we fetch them directly from YouTube when we need them.
That being said, identifying which images should be cropped shouldnāt be that difficult. You can look at the URL for this:
https://img.youtube.com/vi/dsVAzSG6SbM/hqdefault.jpg
maxresdefault
hqdefault
mqdefault
hqdefault
.While a tad weird, they are predictable. My guess is that the 4:3 format is a legacy size they still use for the sake of compatibility.
For displaying 16:9 images, itās as simple as fixing the aspect ratio. If you need other aspect ratios, I think you should be good passing a flag and compensating the scale with CSS.
Itās true that the composer preview can be improved, but this could be done with a similar approach as described above.
The only edge case I can see with this approach is with vertical videos with low-res thumbnails. In that case, the black bars are not shown.
But core does create and store irs own derived thumbnails at various resolutions as part of the cooking post process?
This is where the black bars are retained.
Bingo!
But in any case thatās super helpful information which I may be able to use to improve my plugin. Thanks a lot!
Thatās a lot more straightforward than asking GPT-4 Vision if there are black bars or using image magick to detect them.
Thanks to your insight Iāve updated Topic List Previews with a much simpler solution which doesnāt have to be toggled as it will only crop if the image is a youtube legacy 4:3 thumbnail.
Perhaps this is general enough to be useful to core?