fixes multiple script rendering

This commit is contained in:
buttle 2021-08-30 18:38:04 +02:00
parent 5ccd8cb174
commit a7ad58b452
3 changed files with 23 additions and 19 deletions

View File

@ -1,4 +0,0 @@
function get_height(container, ratio) {
var height = $(container).width() / ratio
return height
}

View File

@ -0,0 +1,20 @@
function get_height(container, ratio) {
var height = $(container).width() / ratio
return height
}
function adjust_height() {
$(".embeded-vimeo-wrapper").each(function() {
var iframe = $(this).find('iframe')
var ratio = $(iframe).attr('ratio')
$(iframe).prop("height", get_height(iframe, ratio))
});
}
jQuery(document).ready(function() {
adjust_height();
});
$(window).resize(function() {
adjust_height();
});

View File

@ -1,9 +1,9 @@
<?php <?php
$this->headScript()->appendFile($this->assetUrl('js/height_calculator.js', $this->headScript()->appendFile($this->assetUrl('js/media_dimensions.js',
'Vimeo')); 'Vimeo'));
?> ?>
<div class="archive-embeded-media-wrapper" <div class="embeded-vimeo-wrapper"
style="position:relative;"> style="position:relative;">
<?php if ($renderSourceLink) { ?> <?php if ($renderSourceLink) { ?>
@ -23,17 +23,5 @@ $this->headScript()->appendFile($this->assetUrl('js/height_calculator.js',
</div> </div>
<script> <script>
function adjust_height() {
$(".archive-embeded-media-wrapper").each(function() {
var iframe = $(this).find('iframe')
var ratio = $(iframe).attr('ratio')
$(iframe).prop("height", get_height(iframe, ratio))
});
}
jQuery(document).ready(function() {
adjust_height();
});
$( window ).resize(function() {
adjust_height();
});
</script> </script>