| Conditions | 9 |
| Paths | 60 |
| Total Lines | 26 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public static function file($path, $resize = '', $resizeCrop = '', $resizePos = '', $pathAbsolute = false) { |
||
| 23 | if (!$path) { |
||
| 24 | $pathAbsolute = false; |
||
| 25 | $path = !empty(App::$primary->config['site']['noimage']) ? App::$primary->config['site']['noimage'] : '/static/system/images/no-image.png'; |
||
| 26 | } |
||
| 27 | |||
| 28 | $absolutePath = $pathAbsolute ? $path : App::$cur->staticLoader->parsePath($path); |
||
| 29 | |||
| 30 | $convert = false; |
||
| 31 | if (!file_exists($absolutePath) && file_exists(mb_convert_encoding($absolutePath, 'Windows-1251', 'UTF-8'))) { |
||
| 32 | $absolutePath = mb_convert_encoding($absolutePath, 'Windows-1251', 'UTF-8'); |
||
| 33 | $convert = true; |
||
| 34 | } |
||
| 35 | if (!file_exists($absolutePath)) { |
||
| 36 | return ''; |
||
| 37 | } else { |
||
| 38 | $options = []; |
||
| 39 | if ($resize) { |
||
| 40 | $resize = explode('x', $resize); |
||
| 41 | $options = ['resize' => ['x' => $resize[0], 'y' => $resize[1]]]; |
||
| 42 | } |
||
| 43 | $options['crop'] = $resizeCrop; |
||
| 44 | $options['pos'] = $resizePos; |
||
| 45 | $path = Cache::file($absolutePath, $options); |
||
| 46 | $path = $convert ? mb_convert_encoding($path, 'UTF-8', 'Windows-1251') : $path; |
||
| 47 | return '/' . $path; |
||
| 48 | } |
||
| 50 | } |