1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Images;
13
14 15 16
17 class Thumbnail extends \ICanBoogie\Modules\Thumbnailer\Thumbnail
18 {
19
20
21 protected function get_url()
22 {
23 $record = $this->src;
24 $options = $this->filtered_options;
25 $version_name = $this->version_name;
26
27 $url = "/api/images/{$record->nid}";
28 $remove_path_params = false;
29
30 if ($version_name)
31 {
32 $url .= "/thumbnails/" . $version_name;
33 }
34 else
35 {
36 $url .= self::format_options_as_path($options);
37 $remove_path_params = true;
38 }
39
40 $query_string = self::format_options_as_query_string($options, true);
41
42 if ($query_string)
43 {
44 $url .= '?' . $query_string;
45 }
46
47 return $url;
48 }
49
50 public function to_element(array $attributes=[])
51 {
52 $element = parent::to_element($attributes);
53
54 $record = $this->src;
55
56 list($w, $h) = \ICanBoogie\Image::compute_final_size($this->w, $this->h, $this->method, [ $record->width, $record->height ]);
57
58 $element['alt'] = $record->alt;
59 $element['width'] = $w;
60 $element['height'] = $h;
61
62 return $element;
63 }
64 }