Total Complexity | 7 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | trait ThumbnailTrait |
||
16 | { |
||
17 | /** |
||
18 | * @var array|null|ActiveRecord|Mediafile |
||
19 | */ |
||
20 | protected $thumbnailModel; |
||
21 | |||
22 | /** |
||
23 | * Get album thumb image. |
||
24 | * |
||
25 | * @param array $options |
||
26 | * |
||
27 | * @return mixed |
||
28 | */ |
||
29 | public function getDefaultThumbImage(array $options = []) |
||
30 | { |
||
31 | $thumbnailModel = $this->getThumbnailModel(); |
||
32 | |||
33 | if (null === $thumbnailModel){ |
||
34 | return null; |
||
35 | } |
||
36 | |||
37 | $url = $thumbnailModel->getThumbUrl(MFUModule::THUMB_ALIAS_DEFAULT); |
||
38 | |||
39 | if (empty($url)) { |
||
40 | return null; |
||
41 | } |
||
42 | |||
43 | if (empty($options['alt'])) { |
||
44 | $options['alt'] = $thumbnailModel->alt; |
||
45 | } |
||
46 | |||
47 | return Html::img($url, $options); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Get model's thumbnail. |
||
52 | * |
||
53 | * @return array|null|\yii\db\ActiveRecord|Mediafile |
||
54 | */ |
||
55 | public function getThumbnailModel() |
||
66 | } |
||
67 | } |