forces iframe width with jquery

This commit is contained in:
buttle 2021-06-22 11:53:13 +02:00
parent 92da216cff
commit fd225e386b
4 changed files with 21 additions and 1 deletions

View File

@ -9,6 +9,12 @@ class Module extends AbstractModule
{
const NAMESPACE = __NAMESPACE__;
const RATIOS = [
'1.777' => '16:9',
'1.333' => '4:3',
'2' => '2:1',
];
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';

View File

@ -31,6 +31,7 @@ return [
'SketchfabBlockForm' => [
'title' => '',
'width' => 600,
'ratio' => '2',
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
]
]

View File

@ -75,8 +75,12 @@ class Sketchfab extends AbstractBlockLayout
static $id = 0;
$media = $attachments[0]->item()->media()[0];
$width = 900;
$height = $width / $block->dataValue('ratio');
return $view->partial('common/block-layout/sketchfab', [
'title' => false,
'width' => $width,
'height' => $height,
'sketchfab_iframe' => $media->mediaData()['html'],
]);
//return $media->mediaData()['html'];

View File

@ -1,4 +1,4 @@
<div class="archive_org-wrap" style="position:relative;">
<div class="sketchfab-wrap" style="position:relative;">
<?php
if ($title !== false && $title !== "") {
@ -11,3 +11,12 @@
<?= $sketchfab_iframe ?>
</div>
<script>
jQuery(document).ready(function() {
var sketchfab = $(".sketchfab-wrap").find('iframe');
$(sketchfab).prop('width', <?= $width ?>);
$(sketchfab).prop('height', <?= $height ?>);
});
</script>