defines image width with percentages

This commit is contained in:
buttle 2021-04-19 14:24:34 +02:00
parent 7c1ee9d4d7
commit d86e63b9f5
4 changed files with 19 additions and 17 deletions

View File

@ -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';

View File

@ -21,12 +21,10 @@ 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,
],
]);

View File

@ -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,
]);

View File

@ -20,9 +20,8 @@
?>
<style>
.archive-img {
width: <?= $width ?>px;
<!-- width: 50%; -->
#<?= $id ?> {
width: <?= $width ?>%;
}
<?php if ($zoom == true) { ?>
#<?= $id ?> {
@ -57,7 +56,6 @@
});
*/
</script>
<?php } ?>
</div>