I am trying to add an embed html5 video for some thumbnails. The embed code I have below works fine for desktop, but on mobile i’d like to just use an image. I’ve tried adding a media query in the section, but not an expert on that. Any help would be appreciated. Thank you.
Class 1 - show on desktop(video) - visible on destkop - hidden on tablet and below
Class 2 - show on mobile (image) - the opposite (deskop hide - mobile show).
Now because you set the video to autoplay - stop the video by code (More safety).
Copy-paste before body for this page only (Under page-setting).
<!-- Disable HTML5 video autoplay only on smartphone -->
<script>
$(document).ready(function(){
var videoElement = $(".projectvideo video"); /* select the video element inside projectvideo class */
var screenWidth = $(window).width();
// if window width is smaller than 800 remove the autoplay attribute
// from the video
if (screenWidth < 800){
videoElement.removeAttr('autoplay');
} else {
videoElement.attr('autoplay');
}
});
</script>
naming & code above
Do not change the class name projectvideo on webflow (Or change and remember to update the code).