| Total Complexity | 6 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | class ImageAsset extends Asset { |
||
| 10 | |||
| 11 | public $type = ImageAsset::class; |
||
| 12 | public $namespace = 'property'; |
||
| 13 | |||
| 14 | public static function getImageUrl($filename, $width = null, $height = null){ |
||
| 15 | |||
| 16 | $imagePath = public_path().'/vendor/phpsa-datastore/'; |
||
| 17 | |||
| 18 | if ($width || $height) { |
||
| 19 | $path = 'thumbs/' . $width . 'x' . $height . '.' . $filename; |
||
| 20 | |||
| 21 | if(!is_file($imagePath . $path)){ |
||
| 22 | try{ |
||
| 23 | Image::make(public_path().'/vendor/phpsa-datastore/img/' . $filename)->resize($width,$height, function ($constraint) { |
||
| 24 | $constraint->aspectRatio(); |
||
| 25 | })->save($imagePath . $path); |
||
| 26 | }catch(Exception $e){ |
||
|
|
|||
| 27 | //Silent fallback as the image does not exist! |
||
| 28 | } |
||
| 29 | } |
||
| 30 | }else{ |
||
| 31 | $path = 'img/' . $filename; |
||
| 32 | } |
||
| 33 | return '/vendor/phpsa-datastore/' . $path; |
||
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | } |
||
| 38 | |||
| 39 | public static function html($data) { |
||
| 42 | } |
||
| 43 | |||
| 47 |