| Conditions | 7 |
| Paths | 4 |
| Total Lines | 34 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 3 | Features | 0 |
| 1 | <?php |
||
| 25 | public function resize($image) |
||
| 26 | { |
||
| 27 | $absolute_path = $this->webroot . $image; |
||
| 28 | $absolute_info = pathinfo($absolute_path); |
||
| 29 | $allowedExtension = ['jpg','JPG','jpeg',"JPEG",'png','PNG','gif','GIF']; |
||
| 30 | $extension = pathinfo($image); |
||
| 31 | |||
| 32 | if(in_array($extension['extension'],$allowedExtension)) |
||
| 33 | { |
||
| 34 | if(!empty($this->options)) |
||
| 35 | { |
||
| 36 | foreach($this->options['size'] as $k=>$v) |
||
| 37 | { |
||
| 38 | $width = $v['width']; |
||
| 39 | $height = $v['height']; |
||
| 40 | $dest = $absolute_info['dirname'] . '/' . $absolute_info['filename'] . "_$width" . "x$height" . '.jpg'; |
||
| 41 | |||
| 42 | if(file_exists($dest)) |
||
| 43 | { |
||
| 44 | return false; |
||
| 45 | } |
||
| 46 | |||
| 47 | $imagine = new \Imagine\Gd\Imagine(); |
||
| 48 | $mode = $this->options['mode']; |
||
| 49 | |||
| 50 | $imagine->open($absolute_info['dirname'] . '/' . $absolute_info['filename'] . '.jpg') |
||
| 51 | ->thumbnail(new \Imagine\Image\Box($width,$height), !empty($mode) && $mode == 'inset' ? ImageInterface::THUMBNAIL_INSET : ImageInterface::THUMBNAIL_OUTBOUND) |
||
| 52 | ->save($dest); |
||
| 53 | } |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | return true; |
||
| 58 | } |
||
| 59 | } |
||
| 60 |