getTransferAdapter()->getResize(); } public function setResize($spec) { $this->getTransferAdapter()->setResize($spec); return $this; } public function setThumbnailWidth($width) { $this->_thumbnailWidth = (int) $width; return $this; } public function setThumbnailHeight($height) { $this->_thumbnailHeight = (int) $height; return $this; } public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return $this; } $decorators = $this->getDecorators(); if (empty($decorators)) { $this->addDecorator('ExtendedImage') ->addDecorator('Errors') ->addDecorator('Description') ->addDecorator('HtmlTag', array('tag' => 'dd', 'id' => $this->getName() . '-element')) ->addDecorator('Label', array('tag' => 'dt')); } return $this; } public function getDownloadUrl($value = null) { if (null === $this->_downloadUrl) { if (null === $value) { $value = $this->getValue(); } $file = $this->getTransferAdapter()->getDestination($this->getName()) . '/' . $value; $file = str_replace(WWW_PATH . '/' . Qs_ImageFs::WEB_PATH . '/', '', $file); $this->_downloadUrl = BASE_URL . '/' . Qs_ImageFs::get($file); } return $this->_downloadUrl; } public function getThumbnail() { if (null === $this->_thumbnail) { $file = $this->getTransferAdapter()->getDestination($this->getName()) . '/' . $this->getValue(); $file = str_replace(WWW_PATH . '/' . Qs_ImageFs::WEB_PATH . '/', '', $file); $this->_thumbnail = Qs_ImageFs::get($file, $this->_thumbnailWidth, $this->_thumbnailHeight); } return $this->_thumbnail; } public function isValid($value, $context = null) { $this->getValidators(); // autoinsert IsImage validator return parent::isValid($value, $context); } public function getValidators() { if (null == $this->getValidator('IsImage')) { $this->addValidator('File_IsImage', true); } return parent::getValidators(); } public function setDefaultThumbnail($thumbnail) { $path = WWW_PATH . '/' . $thumbnail; if (!file_exists($thumbnail) && is_file($path)) { throw new Qs_Exception('File "' . $thumbnail . '" does not exist'); } $this->_defaultThumbnail = $thumbnail; return $this; } public function getDefaultThumbnail() { if ($this->_defaultThumbnail) { return Qs_ImageFs::get($this->_defaultThumbnail, $this->_thumbnailWidth, $this->_thumbnailHeight); } return false; } }