diff --git a/Module.php b/Module.php index 9280d3e..07310a0 100644 --- a/Module.php +++ b/Module.php @@ -9,6 +9,13 @@ class Module extends AbstractModule { const NAMESPACE = __NAMESPACE__; + const IMAGE_WIDTH = [ + '25' => '25 %', + '50' => '50 %', + '75' => '75 %', + '100' => '100 %', + ]; + public function getConfig() { return include __DIR__ . '/config/module.config.php'; diff --git a/src/Form/ImageViewerBlockForm.php b/src/Form/ImageViewerBlockForm.php index 4dddc64..1708ccb 100644 --- a/src/Form/ImageViewerBlockForm.php +++ b/src/Form/ImageViewerBlockForm.php @@ -21,13 +21,11 @@ class ImageViewerBlockForm extends Form $this->add([ 'name' => 'o:block[__blockIndex__][o:data][width]', - 'type' => Element\Number::class, + 'type' => Element\Select::class, 'options' => [ - 'label' => 'Width in pixels', - ], - 'attributes' => [ - 'min' => '100', - ], + 'label' => 'Width', + 'value_options' => Module::IMAGE_WIDTH, + ], ]); $this->add([ diff --git a/src/Site/BlockLayout/ImageViewer.php b/src/Site/BlockLayout/ImageViewer.php index 4608ee2..816a300 100644 --- a/src/Site/BlockLayout/ImageViewer.php +++ b/src/Site/BlockLayout/ImageViewer.php @@ -74,11 +74,10 @@ class ImageViewer extends AbstractBlockLayout static $id = 0; $media = $attachments[0]->item()->media()[0]; - $width = $block->dataValue('width'); return $view->partial('common/block-layout/imageViewer', [ 'zoom' => $block->dataValue('zoom'), 'title' => $block->dataValue('title'), - 'width' => $width, + 'width' => $block->dataValue('width'), 'image' => $media->primaryMedia()->thumbnailUrl('large'), 'id' => 'iv-' . ++$id, ]); diff --git a/view/common/block-layout/imageViewer.phtml b/view/common/block-layout/imageViewer.phtml index 83c5a53..cf7b4bb 100644 --- a/view/common/block-layout/imageViewer.phtml +++ b/view/common/block-layout/imageViewer.phtml @@ -20,9 +20,8 @@ ?>