Webflow sync, pageviews & more.
NEW

Can Webflow buttons or thumbnails be used to change the video in the video player?

TL;DR
  • Embed a YouTube or Vimeo iframe using a custom HTML Embed element on your Webflow page.
  • Add buttons or thumbnails with custom data-video-id or data-video-url attributes.
  • Use custom JavaScript to listen for clicks and update the iframe's src dynamically.
  • Optionally use YouTube or Vimeo APIs for advanced video control without iframe reload.

Webflow does not support native video swapping with buttons or thumbnails out of the box, but it can be achieved using custom embed elements and minimal custom code.

1. Use Custom HTML Embed for Video

  • Add an Embed element anywhere on your Webflow page where you want the video to appear.
  • Embed a YouTube or Vimeo iframe, using a placeholder video.
  • Example: <iframe id="main-video" src="https://www.youtube.com/embed/VIDEO_ID?rel=0" loading="lazy" allowfullscreen></iframe>

2. Create Buttons or Thumbnails

  • Add Buttons, Links, or Images to act as video selectors.
  • For each button/thumbnail, use a custom attribute like data-video-id (for YouTube) or data-video-url.
  • Example: A thumbnail set with data-video-id="dQw4w9WgXcQ".

3. Add Custom Code to Swap Video

  • In your Page Settings or using an Embed component at the bottom of the page body, add a small <script> that listens for click events and changes the src of the iframe.
  • Example logic (summary only; not the actual code block):
  • Use document.querySelectorAll to find all video buttons/thumbnails.
  • On click, extract the data-video-id or URL.
  • Update the src of the #main-video iframe using JavaScript.

4. Consider Vimeo or YouTube APIs for Advanced Control

  • For seamless transitions without reloading the iframe, you can use the YouTube Player API or Vimeo Player API.
  • This requires more advanced scripting but allows full control (e.g., play, pause, swap video dynamically).

Summary

Webflow doesn't natively support switching videos via buttons, but you can embed a video iframe and use buttons or thumbnails with data- attributes and custom JavaScript to swap the video URL dynamically.

Rate this answer

Other Webflow Questions