Home › Forums › WoodMart support forum › Youtube-Videos too small › Reply To: Youtube-Videos too small
March 29, 2022 at 1:22 pm
#364925
Bogdan Donovan
Keymaster
Try to add the following code snippet to the Custom JS on the document ready area in Theme Settings to fix this issue.
function customVideoResize() {
document.querySelectorAll( 'iframe, object, video' ).forEach( function( video ) {
var ratio, iTargetWidth,
container = video.parentNode;
// Skip videos we want to ignore.
if ( video.classList.contains( 'intrinsic-ignore' ) || video.parentNode.classList.contains( 'intrinsic-ignore' ) ) {
return true;
}
if ( ! video.dataset.origwidth ) {
// Get the video element proportions.
video.setAttribute( 'data-origwidth', video.width );
video.setAttribute( 'data-origheight', video.height );
}
iTargetWidth = container.offsetWidth;
// Get ratio from proportions.
ratio = iTargetWidth / video.dataset.origwidth;
// Scale based on ratio, thus retaining proportions.
video.style.width = iTargetWidth + 'px';
video.style.height = ( video.dataset.origheight * ratio ) + 'px';
} );
}
customVideoResize()
window.addEventListener( 'resize', function() {
customVideoResize()
});
window.addEventListener( 'load', function() {
customVideoResize()
});
Kind Regards