Compare commits
2 Commits
92fe4b4791
...
53825ef00e
Author | SHA1 | Date |
---|---|---|
buttle | 53825ef00e | |
buttle | dbad2508c7 |
|
@ -15,6 +15,13 @@ class Module extends AbstractModule
|
||||||
'image' => 'Image',
|
'image' => 'Image',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const MODEL_WIDTH = [
|
||||||
|
'25' => '25 %',
|
||||||
|
'50' => '50 %',
|
||||||
|
'75' => '75 %',
|
||||||
|
'100' => '100 %',
|
||||||
|
];
|
||||||
|
|
||||||
const RATIOS = [
|
const RATIOS = [
|
||||||
'1.777' => '16:9',
|
'1.777' => '16:9',
|
||||||
'1.333' => '4:3',
|
'1.333' => '4:3',
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
function get_height(container, ratio) {
|
||||||
|
var height = $(container).width() / ratio
|
||||||
|
return height
|
||||||
|
}
|
|
@ -32,8 +32,8 @@ return [
|
||||||
'media_type' => 'video',
|
'media_type' => 'video',
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'renderSourceLink' => true,
|
'renderSourceLink' => true,
|
||||||
'width' => 600,
|
'width' => 100,
|
||||||
'ratio' => '2',
|
'ratio' => '1.777',
|
||||||
'autoLoad' => false,
|
'autoLoad' => false,
|
||||||
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
|
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
|
||||||
]
|
]
|
||||||
|
|
|
@ -21,13 +21,11 @@ class ArchiveOrgBlockForm extends Form
|
||||||
|
|
||||||
$this->add([
|
$this->add([
|
||||||
'name' => 'o:block[__blockIndex__][o:data][width]',
|
'name' => 'o:block[__blockIndex__][o:data][width]',
|
||||||
'type' => Element\Number::class,
|
'type' => Element\Select::class,
|
||||||
'options' => [
|
'options' => [
|
||||||
'label' => 'Width in pixels',
|
'label' => 'Width',
|
||||||
],
|
'value_options' => Module::MODEL_WIDTH,
|
||||||
'attributes' => [
|
],
|
||||||
'min' => '100',
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->add([
|
$this->add([
|
||||||
|
|
|
@ -76,15 +76,21 @@ class ArchiveOrg extends AbstractBlockLayout
|
||||||
static $id = 0;
|
static $id = 0;
|
||||||
|
|
||||||
$media = $attachments[0]->item()->media()[0];
|
$media = $attachments[0]->item()->media()[0];
|
||||||
|
$media_type = $block->dataValue('media_type');
|
||||||
$width = $block->dataValue('width');
|
$width = $block->dataValue('width');
|
||||||
$height = $width / $block->dataValue('ratio');
|
if ($media_type == "audio") {
|
||||||
|
$height = 32;
|
||||||
|
} else {
|
||||||
|
$height = $width / $block->dataValue('ratio');
|
||||||
|
}
|
||||||
return $view->partial('common/block-layout/archiveOrg', [
|
return $view->partial('common/block-layout/archiveOrg', [
|
||||||
'media_type' => $block->dataValue('media_type'),
|
'media_type' => $media_type,
|
||||||
'title' => $block->dataValue('title'),
|
'title' => $block->dataValue('title'),
|
||||||
'renderSourceLink' => $block->dataValue('renderSourceLink'),
|
'renderSourceLink' => $block->dataValue('renderSourceLink'),
|
||||||
'item_url' => $attachments[0]->item()->url(),
|
'item_url' => $attachments[0]->item()->url(),
|
||||||
'width' => $width,
|
'width' => $width,
|
||||||
'height' => $height,
|
'height' => $height,
|
||||||
|
'ratio' => $block->dataValue('ratio'),
|
||||||
'url' => $media->source(),
|
'url' => $media->source(),
|
||||||
'id' => 'achive_org-' . ++$id,
|
'id' => 'achive_org-' . ++$id,
|
||||||
'thumbnails' => $thumbnails,
|
'thumbnails' => $thumbnails,
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
<div class="archive_org-wrap" style="position:relative;">
|
<?php
|
||||||
|
$this->headScript()->appendFile($this->assetUrl('js/height_calculator.js',
|
||||||
|
'ArchiveOrg'));
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="archive_org-wrap">
|
||||||
|
|
||||||
<?php if ($renderSourceLink) { ?>
|
<?php if ($renderSourceLink) { ?>
|
||||||
<div class="source-link">
|
<div class="source-link">
|
||||||
|
@ -14,21 +19,16 @@
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if ($media_type != "audio") { ?>
|
|
||||||
<style>
|
|
||||||
#<?= $id ?> {
|
|
||||||
height: <?= $height ?>px;
|
|
||||||
width: <?= $width ?>px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<iframe
|
<iframe
|
||||||
id="<?= $id ?>"
|
id="<?= $id ?>"
|
||||||
src="<?= $url ?>"
|
src="<?= $url ?>"
|
||||||
frameborder="0"
|
frameborder="0"
|
||||||
webkitallowfullscreen="true"
|
webkitallowfullscreen="true"
|
||||||
mozallowfullscreen="true"
|
mozallowfullscreen="true"
|
||||||
|
width="<?= $width ?>%"
|
||||||
|
height="<?= $height ?>"
|
||||||
|
user_defined_ratio="<?= $ratio ?>"
|
||||||
|
media_type="<?= $media_type ?>"
|
||||||
allowfullscreen >
|
allowfullscreen >
|
||||||
</iframe>
|
</iframe>
|
||||||
|
|
||||||
|
@ -39,3 +39,21 @@
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function adjust_height() {
|
||||||
|
$(".archive_org-wrap").each(function() {
|
||||||
|
var iframe = $(this).find('iframe')
|
||||||
|
if ($(iframe).attr("media_type") == 'video') {
|
||||||
|
var height = get_height(iframe, $(iframe).attr("user_defined_ratio"))
|
||||||
|
$(iframe).prop("height", height)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
jQuery(document).ready(function() {
|
||||||
|
adjust_height();
|
||||||
|
});
|
||||||
|
$(window).resize(function() {
|
||||||
|
adjust_height();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue