forked from iandoe/kirbycms-panel-imagepicker-field
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagepicker.php
45 lines (30 loc) · 933 Bytes
/
imagepicker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
global $page;
// Get panel config color
$color = c::get('panel.color');
// is width set ? default value is 100px
$width = isset($width) ? $width : 100;
// Placeholder when there is no images, defaults to panel i18n when empty
$ph = isset($placeholder) ? form::multilangtext($placeholder) : l::get('files.empty');
?>
<style>
ul.thumbnails.image_picker_selector li .thumbnail.selected {
background: <?php echo $color ?>;
}
</style>
<?php if ($page->hasImages()): ?>
<select name="<?php echo $name ?>" class="imagePicker-field">
<?php foreach ($page->images() as $img): ?>
<?php $val = $img->filename(); ?>
<option
value="<?php echo $val ?>"
data-img-src="<?php echo thumb($img, array('width' => $width), false) ?>"
<?php ecco($val == $value ,' selected="selected"') ?>
>
<?php echo $img->name() ?>
</option>
<?php endforeach ?>
</select>
<?php else: ?>
<span><?php echo $ph ?></span>
<?php endif ?>