Skip to content

Commit 6474e51

Browse files
committed
Allow image pulling
1 parent a6cd9ab commit 6474e51

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

config/twill.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
'icon' => 'star-feature',
3535
'component' => 'a17-block-film-review',
3636
],
37-
37+
'image' => [
38+
'title' => 'Image',
39+
'icon' => 'image',
40+
'component' => 'a17-block-image',
41+
]
3842
],
3943
'block_views_path' => 'blocks',
4044
'block_single_layout' => 'admin/block-preview',
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@formField('medias', [
2+
'name' => 'image', // role
3+
'label' => 'Image',
4+
'withVideoUrl' => false,
5+
'translated' => false,
6+
])
7+
8+
@formField('radios', [
9+
'name' => 'float',
10+
'label' => 'Pull',
11+
'inline' => true,
12+
'default' => null,
13+
'options' => [
14+
['value' => null, 'label' => 'No Text Wrap'],
15+
['value' => 'left', 'label' => 'Left'],
16+
['value' => 'right', 'label' => 'Right'],
17+
]
18+
])
19+
20+
@formField('input', [
21+
'name' => 'width',
22+
'label' => 'Width (%)',
23+
'default' => 100,
24+
'type' => 'number',
25+
])

resources/views/blocks/image.blade.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
$hasImage = !empty($media);
44
$credit = $hasImage ? $media->getMetadata('credit') : null;
55
@endphp
6-
<figure>
6+
<figure style="width: {{ $block->input('width') }}%;
7+
@if ($block->input('float') == 'left')
8+
float: left;
9+
margin-right: 2em;
10+
@elseif ($block->input('float') == 'right')
11+
float: right;
12+
margin-left: 2em;
13+
@endif
14+
">
715
<img src="{{ $block->image('image', 'flexible') }}"
816
alt="{{ $block->imageAltText('image') }}"/>
917
<?php $caption = $block->imageCaption('image'); ?>

0 commit comments

Comments
 (0)