defines image width with percentages
This commit is contained in:
parent
7c1ee9d4d7
commit
d86e63b9f5
|
@ -9,6 +9,13 @@ class Module extends AbstractModule
|
||||||
{
|
{
|
||||||
const NAMESPACE = __NAMESPACE__;
|
const NAMESPACE = __NAMESPACE__;
|
||||||
|
|
||||||
|
const IMAGE_WIDTH = [
|
||||||
|
'25' => '25 %',
|
||||||
|
'50' => '50 %',
|
||||||
|
'75' => '75 %',
|
||||||
|
'100' => '100 %',
|
||||||
|
];
|
||||||
|
|
||||||
public function getConfig()
|
public function getConfig()
|
||||||
{
|
{
|
||||||
return include __DIR__ . '/config/module.config.php';
|
return include __DIR__ . '/config/module.config.php';
|
||||||
|
|
|
@ -21,12 +21,10 @@ class ImageViewerBlockForm 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::IMAGE_WIDTH,
|
||||||
'attributes' => [
|
|
||||||
'min' => '100',
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -74,11 +74,10 @@ class ImageViewer extends AbstractBlockLayout
|
||||||
static $id = 0;
|
static $id = 0;
|
||||||
|
|
||||||
$media = $attachments[0]->item()->media()[0];
|
$media = $attachments[0]->item()->media()[0];
|
||||||
$width = $block->dataValue('width');
|
|
||||||
return $view->partial('common/block-layout/imageViewer', [
|
return $view->partial('common/block-layout/imageViewer', [
|
||||||
'zoom' => $block->dataValue('zoom'),
|
'zoom' => $block->dataValue('zoom'),
|
||||||
'title' => $block->dataValue('title'),
|
'title' => $block->dataValue('title'),
|
||||||
'width' => $width,
|
'width' => $block->dataValue('width'),
|
||||||
'image' => $media->primaryMedia()->thumbnailUrl('large'),
|
'image' => $media->primaryMedia()->thumbnailUrl('large'),
|
||||||
'id' => 'iv-' . ++$id,
|
'id' => 'iv-' . ++$id,
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.archive-img {
|
#<?= $id ?> {
|
||||||
width: <?= $width ?>px;
|
width: <?= $width ?>%;
|
||||||
<!-- width: 50%; -->
|
|
||||||
}
|
}
|
||||||
<?php if ($zoom == true) { ?>
|
<?php if ($zoom == true) { ?>
|
||||||
#<?= $id ?> {
|
#<?= $id ?> {
|
||||||
|
@ -57,7 +56,6 @@
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue