/** * Get thumbnail path * * @param string $type * @param Replica_ImageProxy_Abstract $proxy * @return null|string - Relative path to thumbnail */ function thumbnail_path($type, Replica_ImageProxy_Abstract $proxy) { $config = sfReplicaThumbnail::getConfig($type); // Has image if ($proxy->getUid()) { sfReplicaThumbnail::loadMacro($type, $config['macro']); // If image not found return null try { $proxy->setMimeType($config['mimetype']); if (null !== $config['quality']) { $proxy->setQuality($config['quality']); } return sfConfig::get('app_thumbnail_dir') . '/' . Replica::cache()->get($type, $proxy); } catch (Replica_Exception_ImageNotInitialized $e) { if ($config['required']) { throw $e; } return; } // Default image } else { if (isset($config['default'])) { return $config['default']; } } }
/** * Возвращает путь к превьюшке * * @param string $type * @return string */ public function getImagePath($type) { if ($this->isNew() || !$this->size) { $proxy = new Replica_ImageProxy_FromFile(null); } else { $proxy = new sfReplicaImageDoctrine($this); } $config = sfReplicaThumbnail::getConfig($type); // Has image if ($proxy->getUid()) { sfReplicaThumbnail::loadMacro($type, $config['macro']); // If image not found return null try { $path = sfConfig::get('app_thumbnail_dir') . '/' . Replica::cache()->get($type, $proxy, $config['mimetype']); } catch (Replica_Exception_ImageNotInitialized $e) { return; } // Default image } else { if (isset($config['default'])) { $path = $config['default']; } } return $path; }