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 NAMESPACE = __NAMESPACE__;
const RATIOS = [
'1.777' => '16:9',
'1.333' => '4:3',
'2' => '2:1',
];
public function getConfig() public function getConfig()
{ {
return include __DIR__ . '/config/module.config.php'; return include __DIR__ . '/config/module.config.php';

View File

@ -31,6 +31,7 @@ return [
'SketchfabBlockForm' => [ 'SketchfabBlockForm' => [
'title' => '', 'title' => '',
'width' => 600, 'width' => 600,
'ratio' => '2',
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;', '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; static $id = 0;
$media = $attachments[0]->item()->media()[0]; $media = $attachments[0]->item()->media()[0];
$width = 900;
$height = $width / $block->dataValue('ratio');
return $view->partial('common/block-layout/sketchfab', [ return $view->partial('common/block-layout/sketchfab', [
'title' => false, 'title' => false,
'width' => $width,
'height' => $height,
'sketchfab_iframe' => $media->mediaData()['html'], 'sketchfab_iframe' => $media->mediaData()['html'],
]); ]);
//return $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 <?php
if ($title !== false && $title !== "") { if ($title !== false && $title !== "") {
@ -11,3 +11,12 @@
<?= $sketchfab_iframe ?> <?= $sketchfab_iframe ?>
</div> </div>
<script>
jQuery(document).ready(function() {
var sketchfab = $(".sketchfab-wrap").find('iframe');
$(sketchfab).prop('width', <?= $width ?>);
$(sketchfab).prop('height', <?= $height ?>);
});
</script>