1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Images;
13
14 use Brickrouge\A;
15 use Brickrouge\Decorator;
16
17 18 19
20 class ThumbnailDecorator extends Decorator
21 {
22 23 24 25 26
27 protected $record;
28
29 30 31 32 33
34 protected $options = array
35 (
36 'version' => '$icon',
37 'no-lightbox' => false
38 );
39
40 41 42 43 44 45 46
47 public function __construct($component, Image $record, array $options=array())
48 {
49 $this->record = $record;
50 $this->options = $options + $this->options;
51
52 parent::__construct($component);
53 }
54
55 public function render()
56 {
57 $record = $this->record;
58 $thumbnail = $record->thumbnail($this->options['version'])->to_element
59 (
60 array
61 (
62 'data-popover-image' => $record->thumbnail('$popover')->url
63 )
64 );
65
66 if (!$this->options['no-lightbox'])
67 {
68 $thumbnail = new A($thumbnail, $record->path, array('rel' => "lightbox[thumbnail-decorator]"));
69 }
70
71 return $thumbnail . parent::render();
72 }
73 }