Embed video with a custom thumbnail in an iframe

Hello everyone! I'm a first-time user on stackoverflow seeking some help. Currently, I am using Dreamweaver to work with HTML and CSS in order to build a website.

My task involves sourcing a video from a television archive and embedding it onto my site using an iframe element. I would like to know if there is a way to customize the thumbnail image, and even better, create a looping video thumbnail (perhaps utilizing a moving gif?).

Below, you can find the current HTML and CSS code I have implemented. The container is designed to ensure that the site is responsive across different devices, although I admit that my programming skills are not very advanced and there might be cleaner ways to achieve this functionality.

I would greatly appreciate any suggestions or tips. I have attempted various methods to customize the thumbnail based on advice from other sites, but so far without success.

Thank you in advance for any help provided.

You can visit the page here:

HTML Code:

<td width="100%"><div class="container">
      <iframe class="responsive-iframe" 
     width="100%" height="100" src="https://www.salto.nl/embed/future-vision-amsterdam/3nhym5GjLaKGciEcQmw0qU" scrolling="no" overflow="hidden" allowfullscreen allowtransparency="true" frameborder="0"> </iframe>
    </div>

CSS Code:

.container {
    overflow: hidden;
    border: 0;
    position: relative;
    width: 70%;
    margin-left: auto;
    margin-right: auto;
    padding-top: 45%; / 16:9 Aspect Ratio (divide 9 by 16 = 0.5625) /
    scrolling: no;
    background-color: none;

}

/* Style the iframe to fit within the container div with full height and width */
.responsive-iframe {
border: 0;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 86%;
  margin-left: auto;
  margin-right: auto;
  scrolling: no;
  
}

I've attempted overlaying the thumbnail, however, couldn't figure out how to make it disappear when clicked to play the video.

Answer №1

Check out this innovative solution featuring:

  • An embedded thumbnail image in the container
  • The iframe set to 'visibility: hidden' for displaying the thumbnail
  • A click event on the container to toggle the visibility of the iframe

One drawback of this setup is the lack of auto-start functionality for the video. While clicking on the thumbnail reveals the iframe, the video does not play automatically. Is there an API available at that enables auto-start for the video?

function adjustVisibility() {
  var iframes = document.getElementsByClassName('iframe');
  for(i = 0; i < iframes.length; i++) {
    iframes[i].style.visibility = 'visible';
  }
}
.container {
  overflow: hidden;
  border: 0;
  position: relative;
  width: 70%;
  margin-left: auto;
  margin-right: auto;
  padding-top: 45%; /* 16:9 Aspect Ratio (divide 9 by 16 = 0.5625) */
  scrolling: no;
}

/* Styling for the responsive iframe within the container div */
.responsive-iframe {
  border: 0;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 86%;
  margin-left: auto;
  margin-right: auto;
  scrolling: no;
}

/* Set initial visibility of the iframe to hidden */
.iframe {
  visibility: hidden
}
<td width="100%">
  <div class="container" onclick="adjustVisibility()">
    <img class="thumbnail responsive-iframe" src="https://www.salto.nl/wp-content/uploads/sites/4/2023/12/Winter18-Salto-viert-de-feestdagen.jpg"> </img>
    <iframe
    class="iframe responsive-iframe" width="100%" height="100"
      src="https://www.salto.nl/embed/future-vision-amsterdam/3nhym5GjLaKGciEcQmw0qU" scrolling="no" overflow="hidden"
      allowfullscreen allowtransparency="true" frameborder="0">
    </iframe>
  </div>
</td>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Extract CSS properties to generate a dictionary that maps class names to background images

Suppose my CSS looks like this: .featured .featured_1 { background-image: url("http://test.com/image.png"); margin-top:20px; } In that case, the following PHP function: function extractBackgroundImages($css) { if (!preg_match_all('/&bso ...

Centering numerous elements on all screen sizes and devices

Is there a way to align elements in the center of the screen both vertically and horizontally without specifying width and height for mobile and desktop views? How can I make it responsive so that it appears centered on all devices? .parent-container{ ...

Bootstrap the registration form to center it in the layout

https://i.sstatic.net/IWSHz.png Here is the code snippet: <div class="col-md-4 col-md-offset-3">. I am new to Bootstrap and trying to center a form that is currently on the left. I have experimented with different col-md and col-xl numbers, but have ...

Error in identifying child element using class name

I need help accessing the element with the class "hs-input" within this structure: <div class = "hbspt-form".......> <form ....class="hs-form stacked"> <div class = "hs_firstname field hs-form-field"...> <div class = ...

How to set the value of an `<input type="date"` in jQuery

Having trouble figuring out why this code isn't functioning properly. The input field I'm using is a simple 'input type="date"' setup like this.... <input type="date" name="Date"/> I am attempting to have the value automatically ...

The sticky header is malfunctioning due to a null offsetTop value

import React , {useRef, useEffect} from 'react' import './header.css' const nav_links =[ { path:'#home', display:'Home' }, { path:'#about', display:'About& ...

"How to Develop an Eraser Tool Using EaselJs - Exploring Further Possibilities

Currently, I am working on creating a Bitmap eraser on easelJS. I feel like I've made significant progress towards achieving this goal, but I'm still a bit unsure of the next steps... Here is a demo of my progress so far: http://jsfiddle.net/bor ...

Having trouble with jQuery not functioning properly in IE9 when trying to add items to a List

I've created a listbox that allows users to add or remove items. To add an item, they can enter text in a textbox and click the "Add" button, which will prepend the text to the top of the list if it's not already present. I used jQuery to handle ...

Having trouble removing a DOM element with jQuery?

Hey there, I need your help with a jQuery issue I'm facing. I am currently working on cloning a div element that contains a span with a click event attached to it. The purpose of the click event is to remove the newly cloned section from the DOM. Whil ...

In a Next JS project, the CSS Transition fails to activate when a class is dynamically added

In my Next.js project with Tailwind styling, I encountered an issue when using the globals.css file for more complex non-Tailwind CSS styling on a component. To better understand the problem, you can view the Code Sandbox here: https://codesandbox.io/p/sa ...

`Using a Video in a JQuery Carousel`

Currently in the early stages of developing a JQuery Slider that will kick off with a video, transitioning into slideshow mode once the video concludes. My goal is to ensure compatibility with IE9 and lower, as well as iPhone devices, necessitating options ...

select2 with customizable multi-column layout

Looking to create a multi-column select2 with a dynamic number of columns by specifying the number of columns as a data attribute in the select tag, or utilizing another method. <select data-cols="2,6,4"> <!--note data-cols--> < ...

Switch the toggle to activate or deactivate links

My attempt at coding a switch to disable and enable links using CSS is functional in terms of JavaScript, but the appearance is not changing. I am lacking experience in this area. Here is my HTML Button code: <label class="switch" isValue="0"> ...

How to trigger a JavaScript function using a button click

I've been struggling to figure out why my JavaScript code isn't functioning properly within Ionic. Can anyone guide me on how to store a number in a variable, display that variable, and increment it when a button is clicked? I have successfully ...

jQuery does not seem to be able to recognize the plus sign (+)

I am currently developing a calculator program and facing some challenges with the addition function. While the other functions ("/", "-", "*") are working fine, the plus ("+") operation seems to be malfunctioning. Here's the snippet of HTML and JavaS ...

When printing a PDF, a div that is set to 100vh only takes up

After setting the div to be 100vh, I realized that when printing it only takes up half of the page. Adding media print did not make a difference, and even trying to set the height to 100% instead didn't work for PDFs. html, body { height: 100%; ...

Is there a way to create a two-toned horizontal rule tag?

Looking for a way to create a stylish two-toned divider line at the bottom of my header. It should be two pixels tall, with a grey top half and white bottom half. While I considered using two one pixel divs stacked together, I'm hoping there's a ...

When an input field is added to an HTML form, all elements positioned below it automatically inherit its attributes

I have a unique combination of HTML and CSS code that creates an impressive login form: <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>Prepare to be amazed...</title> <l ...

Switching on Closed Captions for HTML5 video while deactivating the standard video controls

I am facing two issues. Whenever I include the track tag in my video element, the default controller of the video pops up, which is causing conflicts with my custom controls. Secondly, I am unable to figure out how to turn closed captions on and off. Thi ...

I'm curious about the location where label_color keys are stored within apache-superset

Version: I have installed a Docker instance of Superset from this source The documentation mentions that colors can be customized based on labels, as explained here. To achieve this, it is necessary to provide a mapping of labels to colors in the JSON ...