public function render($view = null, $layout = null) { // set vars $name = $download = $extension = $id = $modified = $path = $cache = $mimeType = $compress = null; extract($this->viewVars, EXTR_OVERWRITE); $this->viewVars['thumbName'] = $thumbName = md5(json_encode($this->viewVars['params'])); $dir = new Folder(CACHE . 'thumbs', true, 0755); $files = $dir->find($this->viewVars['thumbName']); if (empty($files)) { $pos = strpos($this->viewVars['params']['image'], 'http://'); if ($pos !== FALSE) { $this->_loadExternalFile(); $this->_resizeFile(); unlink($this->viewVars['params']['image']); } else { $this->viewVars['params']['image'] = WWW_ROOT . $this->viewVars['params']['image']; $this->_resizeFile(); } } $modified = @filemtime(CACHE . 'thumbs/' . $thumbName); $pos1 = strrpos($params['image'], '.'); $id = substr($params['image'], $pos1 + 1, 8); $this->response->type($id); $this->viewVars['path'] = CACHE . 'thumbs' . DS . $thumbName; $this->viewVars['download'] = false; $this->viewVars['cache'] = '+1 day'; $this->viewVars['modified'] = '@' . $modified; // Must be a string to work. See MediaView->render() parent::render(); }
/** * * @author Petros Diveris * @version 0.1 * @var string mime */ public function getMedia($mime = 'image') { return MediaView::where('content_id', '=', $this->id)->where('mimetype', 'like', "{$mime}%")->orderBy('tag', 'asc')->orderBy('position', 'asc')->get(); }