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

Ways to modify the data within a column for every row in a table without relying on props in Vue.js (specifically Element-ui)

I've been stuck on this issue for quite some time now. I've created a table with 3 columns, and for the first two columns, I can easily display the contents of each row using the prop property. However, for the third column, I need to display inf ...

Exploring the jungle. Cursor acting strange while dragging

I am currently working on implementing drag-and-drop functionality in my project, utilizing slip.js from slip.js. To enhance the cursor during dragging, I have assigned class="draggable" to each draggable <tr>. The CSS code for this class is: .drag ...

Generate additional tabs

Currently, I am in the process of working on a project where I have a bar that will contain dynamically filled tabs. My goal is to include a (+) image that becomes visible when the bar is full. When a user clicks on this image, the remaining tabs should ap ...

What is the best way to conceal the outline in a popup window?

I have successfully implemented a popup/modal window using JavaScript, but now I need to find a way to hide the outline map container. The initialization code for the map is as follows: self.mapDialogOptions = { autoOpen: false, m ...

Enhancing the functionality of hidden input fields using jQuery

I'm looking to dynamically update the value of a hidden input element when a button is clicked. Here's what I have so far: Hidden Input Element: <input type="hidden" value="action" id="action" /> Buttons: <INPUT name=submit value=~#S ...

Tips for effectively showcasing div elements

https://jsfiddle.net/qz8hL574/1/ for (var key in table) { if (table.hasOwnProperty(key)) { $('<div class="element"></div>').appendTo('#list'); document.getElementsByClassName("element")[key].innerHTML = ...

How can we stop the anchor jump caused by a third-party script?

I'm currently utilizing a third-party script (details provided below) to divide a form into multiple ajax'd pages. However, when I attempt to move on to the next page, it immediately jumps to an anchor at the top of the form. This behavior is unn ...

Issues arise when trying to use jQuery within an AJAX-loaded div on the same page

I have been struggling with this issue for days and have tried looking up solutions online, but haven't had any luck. I attempted changing a '.live' to '.click' in the code, but that didn't work either. In the jquery.ajaxy.js ...

Accordion section appears on the webpage as it is loaded

I am currently working on implementing an accordion feature for my webpage. Everything is functioning correctly when I click the button, but there is one issue - the div opens automatically when the page loads. My goal is to have the div closed initially a ...

Searching for an element with line breaks in its class name on a website using Selenium in Python

I am attempting to extract information from LinkedIn, however I have noticed that the element IDs change every time I refresh the page using Selenium. As a result, I attempted to use class names to locate all elements, but the class names contain newline c ...

What is the best way to eliminate <p><br></p> tags from a summernote value?

When I try to enter text into the summernote textarea for space, I keep getting this code: <p><br></p><p><br></p><p><strong style="font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: just ...

Creating a Submenu with HTML and CSS

After trying several guides on creating sub-menus, some involving JS, I decided to attempt a CSS-only approach. Unfortunately, I have encountered difficulty in making the submenu function correctly. You can view my code on fiddle here: http://jsfiddle.net ...

Empty Firebase currentUser Redirected After Successful Sign In

I have a webpage named index.html which serves as the sign-in page. After a user successfully signs in, I want to redirect them to a new page called home.html, where their email will be displayed. However, I am encountering an issue with getting a null va ...

Adjust dropdown options based on cursor placement within textarea

I have a textarea and a dropdown. Whenever a user selects an option from the dropdown menu, it should be inserted into the text area. However, I am facing a bug where the selected value is being inserted at the end of the text instead of at the current cur ...

Troubleshooting issues with adding child elements in JavaScript

Styling with CSS: ul #allposts li{ height: 50px; width: 50px; background-color: yellow; border: 1px solid yellow; } Creating HTML structure: <ul id = "allposts"></ul> Adding JavaScript functionality: var container = documen ...

What is the best way to format PHP emailed content from a web form?

Currently, I am working on a web contact page and facing an issue where the emails being sent arrive as plain text. I would like to enhance them by adding a background, incorporating the organization's logo, and styling the text to align with the webs ...

Should GIT be utilized for managing version control of HTML pages?

Currently, I am developing an application that automatically generates blog pages in HTML format using JSON files. In addition to this functionality, the app also needs to support versioning for each blog created. The process involves converting JSON dat ...

The Fade In effect in jQuery causes my fixed header to overlap with images on the page

This is the javascript snippet using jquery <script type="text/javascript> $(document).ready(function () { $('#showhidetarget').hide(); $('a#showhidetrigger').click(function () { $('#showhidetarget&apo ...

Incorporating a hyperlink into an HTML submit button

Recently, I started working with MySQL and decided to create a basic registration page. However, upon clicking the submit button, I would like to be redirected to another page, possibly a login page as seen on many websites. I am struggling with figuring ...

Bootstrap: Altering grid column layout for medium and small/extra-small screens

Hello everyone, I'm having a bit of trouble working with Bootstrap. My goal is to create a container with a row that contains three columns of equal width: <div class="row"> <div class="col-md-4" style="background:red;">logo</div& ...