resolutions) { $res = $this->resolutions; $res = ltrim($res, '"'); $res = rtrim($res, '"'); $res = str_replace('\"', '"', $res); return json_decode($res); } return []; } public function deleteResolution($rez) { if ($rez) { $resolutions = $this->resolutionArray; $key = array_search($rez, $resolutions); if (false !== $key) { unset($resolutions[$key]); } $this->resolutions = json_encode($resolutions); } } /** * @return array['id', 'src'] */ public function getImageData($ready = null) { $imageTypes = ['image/jpeg', 'image/png']; if (in_array($this->file_type, $imageTypes)) { $crops = []; //if(!empty($this->resolutionArray)) { foreach ($this->resolutionArray as $rez) { $file = '/_files/ready/' . $this->media_key . '/' . $this->object_key . '/' . $rez . '/' . $this->file_name; if (file_exists($_SERVER['DOCUMENT_ROOT'] . $file)) $crops[$rez] = $file; } //} return [ 'id' => $this->id, 'src_raw' => '/_files/raw/' . $this->media_key . '/' . $this->object_key . '/' . $this->file_name, 'src' => $ready ? '/_files/ready/' . $this->media_key . '/' . $this->object_key . '/' . $ready . '/' . $this->file_name : null, 'file_name' => $this->file_name, 'crops' => array_keys($crops), 'crop_files' => $crops, 'type' => $this->file_type, 'extension' => $this->file_extension, 'size' => number_format($this->file_size / 1024 / 1024, 2, '.', '') . 'M' ]; } return null; } }