-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements to internal YouTube shortcode #3694
Comments
@rhewitt22 Out of curiosity, did you try this on multiple videos with different aspect ratios? |
@rdwatters Everything our videographer handed off to me is 1920x1080 (16:9), which is pretty standard these days. If I were to use another resolution it would be 720p, which is also 16:9. I just tried this on a second video with the same resolution and had (unsurprisingly) the same result. For now I'm just pasting in the shortcode html into my content and removing the inline overflow property. |
We will fix this eventually, but It would be more effectie for you to paste the Hugo youtube shortcode into your |
Thanks for the suggestion. That makes things much simpler. |
@rhewitt22 @bep I was looking into this because I was experiencing issues with the container not being sized correctly. There is definitely something incorrect with the style parameters of the container and the iframe. After some research and help from Jonathan on the Hugo forum, I saw how Zurb Foundation was doing it, and saw how Hugo internal shortcode was doing it, and saw the difference. I took Zurb's style settings, applied them in the same way (inline) into a custom shortcode as Hugo does in its internal shortcode. The result works perfectly and as expected is completely responsive. The captions are correctly located also. The working code is below:
I have this as a custom YouTube shortcode for now but of course it should be fixed in the internal shortcode. Replacing the current style parameters with these will do that. Should I submit a PR? Furthermore, Zurb's CSS had a setting whereby, without specifying the aspect ratio of the video, it would default to standard (4:3) but if you set the parameter of widescreen it would change appropriately. The switch was in the padding-bottom: parameter, where standard was 75% and widescreen was 56.25%. This may be a worthwhile parameter to include in the internal shortcode... something like:
but would default to widescreen if standard was not given. @rdwatters this would address your comment about different aspect ratios, but what I've laid out here only pertains to 16:9 and 4:3. If there were another aspect ratio (which I have to imagine is probably pretty rare, I guess there is anamorphic and some other types but not common) then maybe some logic for an input ratio and the shortcode takes that, does the math, and determines what the padding-bottom should be. Also, there is the option of including another parameter to give the start timecode position of the video. Not sure how best to handle that, but I just wanted to throw that in there for another useful option. Maybe the 1st .Params would be the video link code, 2nd would be the ratio (standard or widescreen), 3rd would be the start-time in seconds:
EDIT 1 The code is here:
This allows the user to leave If there were some way to take a string made of a floating point value and convert it directly into a floating point value, that'd be simpler, but I found no such function in Hugo. EDIT 2
|
I'm super embarrassed to admit I had a stray CSS selector that was causing the issue with the youtube captions. That said with those rules removed there is still the issue of black bars at the top and bottom of the YouTube embedded video. Given the other suggestions from @gaetawoo perhaps this issue should be renamed? Maybe Improvements to internal YouTube shortcode? Sorry for the mixup. |
@rhewitt22 Here is the shortcode that will permit a start and stop timecode for the video. The shortcode shortcut requires that the parameters be in order and each previous one filled or else it won't work. It's not robust, but that part is a bit beyond my skill at the moment.
The entry would be thus:
It works well. |
Embeds now support some other useful features, such as hiding the video title, payer controls and (my favorite) an enhanced privacy mode, shown here checked: Also, here's a link to the iFrame Player API in case you want to play around with the different settings and see which events are fired: https://developers.google.com/youtube/youtube_player_demo |
Regarding responsive Here's an elegant solution for <style>
.wrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
}
.wrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class="wrapper">
<iframe src="//coub.com/embed/bwdx6?muted=false&autostart=false&originalSize=true&startWithHD=true" allowfullscreen="true" frameborder="0"></iframe>
</div> |
Changes: - Add query string params for controls, loop, mute, start, and end - Add iframe loading attribute - Obtain default iframe title from YouTube oEmbed API - Fix autoplay feature - Improve readability Closes gohugoio#3694 Closes gohugoio#9213 Closes gohugoio#10520 Closes gohugoio#10575 Closes gohugoio#10576 Co-authored-by: sgharms <[email protected]>
Changes: - Add query string params for controls, loop, mute, start, and end - Add iframe loading attribute - Obtain default iframe title from YouTube oEmbed API - Fix autoplay feature - Improve readability Closes gohugoio#3694 Closes gohugoio#9213 Closes gohugoio#10520 Closes gohugoio#10575 Closes gohugoio#10576 Co-authored-by: sgharms <[email protected]>
Changes: - Add query string params for controls, loop, mute, start, and end - Add iframe loading attribute - Obtain default iframe title from YouTube oEmbed API - Fix autoplay feature - Improve readability Closes gohugoio#3694 Closes gohugoio#9213 Closes gohugoio#10520 Closes gohugoio#10575 Closes gohugoio#10576 Co-authored-by: sgharms <[email protected]>
Changes: - Add query string params for controls, loop, mute, start, and end - Add iframe loading attribute - Obtain default iframe title from YouTube oEmbed API - Fix autoplay feature - Improve readability Closes gohugoio#3694 Closes gohugoio#9213 Closes gohugoio#10520 Closes gohugoio#10575 Closes gohugoio#10576 Co-authored-by: sgharms <[email protected]>
Changes: - Add query string params for controls, loop, mute, start, and end - Add iframe loading attribute - Obtain default iframe title from YouTube oEmbed API - Fix autoplay feature - Improve readability Closes gohugoio#3694 Closes gohugoio#9213 Closes gohugoio#10520 Closes gohugoio#10575 Closes gohugoio#10576 Co-authored-by: sgharms <[email protected]>
Changes: - Add query string params for controls, loop, mute, start, and end - Add iframe loading attribute - Obtain default iframe title from YouTube oEmbed API - Fix autoplay feature - Improve readability Closes gohugoio#3694 Closes gohugoio#9213 Closes gohugoio#10520 Closes gohugoio#10575 Closes gohugoio#10576 Co-authored-by: sgharms <[email protected]>
Changes: - Add query string params for controls, loop, mute, start, and end - Add iframe loading attribute - Obtain default iframe title from YouTube oEmbed API - Fix autoplay feature - Improve readability Closes #3694 Closes #9213 Closes #10520 Closes #10575 Closes #10576 Co-authored-by: sgharms <[email protected]>
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The built-in Hugo shortcode for embedding YouTube videos obscures captions when the user is not interacting with the video. This is a simple CSS issue related to
overflow: hidden;
being included inline in the go template. I removed this CSS property in Chrome Dev Tools and everything works as expected.overflow: hidden;
Removed overflow:hidden;
From GitHub:
The text was updated successfully, but these errors were encountered: