Skip to content

Instantly share code, notes, and snippets.

@watershed
Last active September 24, 2021 14:10
Show Gist options
  • Save watershed/2035323f04081b02e1f6aa393e328e81 to your computer and use it in GitHub Desktop.
Save watershed/2035323f04081b02e1f6aa393e328e81 to your computer and use it in GitHub Desktop.
Vimeo embedding
<!-- Historically, Vimeo URLs of the following form would work as a straightforward `src` attribute value on an iframe -->
<iframe src="https://player.vimeo.com/video/123456789" width="X" height="Y" allowfullscreen></iframe>
<!-- At some point in September 2021 Vimeo changed this, so that URLs require an `h` parameter to work -->
<iframe src="https://player.vimeo.com/video/123456789?h=8yt65b2a98" width="X" height="Y" allowfullscreen></iframe>
<!--
In the above examples:
* `123456789` should be your video ID and `8yt65b2a98` should be its unique key.
* The X and Y width and height values should be replaced with
whatever numbers work for your context. I like to use width="336" height="189"
as a decent mobile friendly baseline of 16:9 proportions.
What HTML your iframe is wrapped in should take care of how it ends up getting
styled to fit its container. For basic usage, Vimeo’s *full* embed code works,
but I like to get rid of all the cruft.
-->
@watershed
Copy link
Author

watershed commented Sep 21, 2021

The canonical page for the example video above would be:

https://vimeo.com/123456789/8yt65b2a98

So this can be coerced into the embed schema with a regular expression (regex) like this:

Regex search pattern:

^.*vimeo\.com/([0-9]+)/(.*)$

Regex replacement pattern:

https://player.vimeo.com/video/$1?h=$2

This could, for example, be applied to a regular Vimeo URL in cell A2 in a Google Sheet, to output the embed equivalent in a neighbouring column with:

=REGEXREPLACE(A2,"^.*vimeo.*com/([0-9]+)/(.*)$", "https://player.vimeo.com/video/$1?h=$2")

Any additional URL parameters, such as autoplay=1, should be appended (with a preceding &), so the spreadsheet formula could be adapted to:

=REGEXREPLACE(A2,"^.*vimeo.*com/([0-9]+)/(.*)$", "https://player.vimeo.com/video/$1?h=$2&autoplay=1")

@stevenjwright
Copy link

Thanks for this 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment