adds default image width

This commit is contained in:
buttle 2021-09-07 11:17:12 +02:00
parent 275e237a5d
commit 412f525d4c
4 changed files with 12 additions and 2 deletions

View File

@ -21,7 +21,7 @@ return [
'SmartGalleryBlockForm' => [
'title' => '',
'renderSourceLink' => true,
'width' => 600,
'width' => 200,
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
]
]

View File

@ -10,6 +10,14 @@ class SmartGalleryBlockForm extends Form
public function init()
{
$this->add([
'name' => 'o:block[__blockIndex__][o:data][width]',
'type' => Element\Text::class,
'options' => [
'label' => 'Individual image width (px)',
],
]);
$this->add([
'type' => Element\Checkbox::class,
'name' => 'o:block[__blockIndex__][o:data][renderSourceLink]',

View File

@ -48,6 +48,7 @@ class SmartGallery extends AbstractBlockLayout
: $this->defaultSettings;
$form->setData([
'o:block[__blockIndex__][o:data][title]' => $data['title'],
'o:block[__blockIndex__][o:data][width]' => $data['width'],
'o:block[__blockIndex__][o:data][renderSourceLink]' => $data['renderSourceLink'],
]);
$form->prepare();
@ -103,6 +104,7 @@ class SmartGallery extends AbstractBlockLayout
'gallery_id' => 'ig_' . ++$gallery_id,
'title' => $block->dataValue('title'),
'images' => $images,
'width' => $block->dataValue('width'),
'renderSourceLink' => $block->dataValue('renderSourceLink'),
]);
}

View File

@ -30,7 +30,7 @@ $this->headLink()->appendStylesheet($this->assetUrl('css/style.css',
<img src="<?= $image['media_url'] ?>"
alt=""
item_url="<?= $image['item_url'] ?>"
width="250"
width="<?= $width ?>"
/>
</a>
</div>