Skip to content
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

tpl: Improve internal YouTube Shortcode #9414

Closed
wants to merge 2 commits into from

Conversation

roointan
Copy link
Contributor

Added support for displaying Embedded YouTube player in 4:3 ratio, in addition to the default widescreen ratio. Also added support for all the latest parameters supported by embedded YouTube player including start/end time, looping, language, playlist, etc. Also added support for for diaplying a linked thumbnail to the YouTube video, instead of the embedded plyaer using the "linkthumbnail" parameter.

Fixes #3694

Added support for displaying Embedded YouTube player in 4:3 ratio, in addition to the default widescreen ratio. Also added support for all the latest parameters supported by embedded YouTube player including start/end time, looping, language, playlist, etc. Also added support for for diaplying a linked thumbnail to the YouTube video, instead of the embedded plyaer using the "linkthumbnail" parameter.

Fixes 3694
Added support for displaying Embedded YouTube player in 4:3 ratio, in addition to the default widescreen ratio. Also added support for all the latest parameters supported by embedded YouTube player including start/end time, looping, language, playlist, etc. Also added support for for diaplying a linked thumbnail to the YouTube video, instead of the embedded plyaer using the "linkthumbnail" parameter.

Fixes 3694
@fgm
Copy link

fgm commented Jan 24, 2022

Thanks a lot for linkthumbnail

@gwatts
Copy link
Contributor

gwatts commented Jan 24, 2022

Thanks for your work on this - I thought i'd try it and see whether it could also be used to play videos stored in Google Drive (in our case, for videos we share internally in the org).

It works great if I change the iframe source from youtube to https://drive.google.com/file/d/{{ $id }}/preview - Would be nice to have that as an option. Not all of the parameters seem to be accepted by the drive embedded player, but it's still very useful

@roointan
Copy link
Contributor Author

Thanks for your work on this - I thought i'd try it and see whether it could also be used to play videos stored in Google Drive (in our case, for videos we share internally in the org).

It works great if I change the iframe source from youtube to https://drive.google.com/file/d/{{ $id }}/preview - Would be nice to have that as an option. Not all of the parameters seem to be accepted by the drive embedded player, but it's still very useful

I'm very glad to find out people are already finding the changes helpful. I'm kinda new to contributing to Hugo. What you've asked for is an easy change. But I prefer to hear back from maintainers before working on more changes. Maybe you can add that to the original issue, or start a forum post? I'm not sure. (I'm afraid about maintainers not agree about adding this)
After I know supporting google drive also belongs to this shortcode, I'll be more than happy to add it.

@davidsneighbour
Copy link
Contributor

davidsneighbour commented Jan 25, 2022

It's an internal shortcode named youtube. Not video. To use specifically modified versions of an internal shortcode copy the content to a file at layouts/shortcodes/shortcodename.html and add your changes there. It will then override the internal shortcode.

@gwatts
Copy link
Contributor

gwatts commented Jan 25, 2022

@davidsneighbour You're right, it's not intended as a generic video shortcode - my point is that video streamed from google drive basically is youtube - It's essentially the same system; i can supply the same "controls=false" parameters, and the controls go away just as they do with youtube. No surprise given they're both owned by Google.

Duplicating a shortcode just to change a URL is a waste of time and gives me yet something else to track for updates and improvements.

@roointan
Copy link
Contributor Author

@bep Could you take a look at this PR too?

@bep bep requested a review from jmooring May 25, 2022 09:51
@jhenstridge
Copy link

For what it is worth, you could probably make the title and aspect ratio settings automatic using YouTube's oembed endpoint, similar to how the Twitter shortcode does with getJSON.

For example:

$ curl 'https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ' | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   793    0   793    0     0   1439      0 --:--:-- --:--:-- --:--:--  1439
{
  "title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
  "author_name": "Rick Astley",
  "author_url": "https://www.youtube.com/c/RickastleyCoUkOfficial",
  "type": "video",
  "height": 113,
  "width": 200,
  "version": "1.0",
  "provider_name": "YouTube",
  "provider_url": "https://www.youtube.com/",
  "thumbnail_height": 360,
  "thumbnail_width": 480,
  "thumbnail_url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg",
  "html": "<iframe width=\"200\" height=\"113\" src=\"https://www.youtube.com/embed/dQw4w9WgXcQ?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen title=\"Rick Astley - Never Gonna Give You Up (Official Music Video)\"></iframe>"
}

Even if you ignore the HTML embed it suggests, we've got the title and thumbnail URL, and checking width/height tells us the video aspect ratio.

Some other thoughts:

  • The oembed data suggests using i.ytimg.com for thumbnails instead of img.youtube.com. My browser sends my login cookie to the latter but not the former, so ytimg is probably better from a privacy perspective.
  • The new linkthumbnail mode seems like it would be useful from a GDPR compliance standpoint. What do you think about having it enabled through the privacy configuration like the "simple" variants of other shortcodes?

@roointan roointan closed this Sep 3, 2022
@github-actions
Copy link

github-actions bot commented Sep 4, 2023

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improvements to internal YouTube shortcode
6 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy