Public Member Functions | |
setConfig (Mage_Media_Model_Image_Config_Interface $config) | |
getConfig () | |
getImage () | |
getTmpImage () | |
getDimensions () | |
getDestanationDimensions () | |
getExtension () | |
getFilePath ($useParams=false) | |
getFileUrl ($useParams=false) | |
getName () | |
addParam ($param, $value=null) | |
setParam ($param, $value=null) | |
getParam ($param) | |
getParams () | |
getParamsSum () | |
getSpecialLink ($file, $size, $extension=null, $watermark=null) | |
hasSpecialImage () | |
Protected Member Functions | |
_construct () | |
_removeResources () | |
Protected Attributes | |
$_config | |
$_image | |
$_tmpImage | |
$_params = array() |
Definition at line 35 of file Image.php.
_construct | ( | ) | [protected] |
Enter description here...
Reimplemented from Varien_Object.
Definition at line 66 of file Image.php.
00067 { 00068 $this->_init('media/image'); 00069 }
_removeResources | ( | ) | [protected] |
Definition at line 269 of file Image.php.
00270 { 00271 if ($this->_image) { 00272 $this->_getResource()->destroyResource($this->_image); 00273 $this->_image = null; 00274 } 00275 00276 if ($this->_tmpImage) { 00277 $this->_getResource()->destroyResource($this->_tmpImage); 00278 $this->_tmpImage = null; 00279 } 00280 }
addParam | ( | $ | param, | |
$ | value = null | |||
) |
getDestanationDimensions | ( | ) |
Retrive destanation dimensions object
Definition at line 129 of file Image.php.
00130 { 00131 if(!$this->getData('destanation_dimensions')) { 00132 $this->setData('destanation_dimensions', clone $this->getDimensions()); 00133 } 00134 00135 return $this->getData('destanation_dimensions'); 00136 }
getDimensions | ( | ) |
Retrive source dimensions object
Definition at line 116 of file Image.php.
00117 { 00118 if(!$this->getData('dimensions')) { 00119 $this->setData('dimensions', $this->_getResource()->getDimensions($this)); 00120 } 00121 return $this->getData('dimensions'); 00122 }
getExtension | ( | ) |
getFilePath | ( | $ | useParams = false |
) |
Definition at line 143 of file Image.php.
00144 { 00145 if($useParams && sizeof($this->getParams())) { 00146 $changes = '.' . $this->getParamsSum(); 00147 } else { 00148 $changes = ''; 00149 } 00150 00151 return $this->getConfig()->getBaseMediaPath() . DS . $this->getName() . $changes . '.' 00152 . ( ( $useParams && $this->getParam('extension')) ? $this->getParam('extension') : $this->getExtension() ); 00153 }
getFileUrl | ( | $ | useParams = false |
) |
Definition at line 155 of file Image.php.
00156 { 00157 if($useParams && sizeof($this->getParams())) { 00158 $changes = '.' . $this->getParamsSum(); 00159 } else { 00160 $changes = ''; 00161 } 00162 00163 return $this->getConfig()->getBaseMediaUrl() . '/' . $this->getName() . $changes . '.' 00164 . ( ( $useParams && $this->getParam('extension')) ? $this->getParam('extension') : $this->getExtension() ); 00165 }
getImage | ( | ) |
Definition at line 93 of file Image.php.
00094 { 00095 if(is_null($this->_image)) { 00096 $this->_image = $this->_getResource()->getImage($this); 00097 } 00098 00099 return $this->_image; 00100 }
getName | ( | ) |
getParam | ( | $ | param | ) |
getParams | ( | ) |
getParamsSum | ( | ) |
getSpecialLink | ( | $ | file, | |
$ | size, | |||
$ | extension = null , |
|||
$ | watermark = null | |||
) |
Return special link (with creating image if not exists)
string | $file | |
string | $size | |
string | $extension | |
string | $watermark |
Definition at line 222 of file Image.php.
00223 { 00224 $this->_removeResources(); 00225 $this->setData(array()); 00226 $this->setParam(array()); 00227 $this->setFileName($file); 00228 00229 $this->addParam('size', $size); 00230 $this->addParam('watermark', $watermark); 00231 $this->addParam('extension', $extension); 00232 00233 if(!$this->hasSpecialImage()) { 00234 if (strpos($size, 'x')!==false) { 00235 list($width, $height) = explode('x', $size); 00236 } else { 00237 $width = $size; 00238 $height = $this->getDimensions()->getHeight(); 00239 } 00240 00241 $sizeHRate = $width / $this->getDimensions()->getWidth(); 00242 $sizeVRate = $height / $this->getDimensions()->getHeight(); 00243 00244 $rate = min($sizeHRate, $sizeVRate); 00245 00246 if ($rate > 1) { // If image smaller than needed 00247 $rate = 1; 00248 } 00249 00250 $this->getDestanationDimensions() 00251 ->setWidth($rate*$this->getDimensions()->getWidth()) 00252 ->setHeight($rate*$this->getDimensions()->getHeight()); 00253 00254 00255 $this->_getResource()->resize($this); 00256 $this->_getResource()->watermark($this); 00257 $this->_getResource()->saveAs($this, $extension); 00258 $this->_removeResources(); 00259 } 00260 00261 return $this->getFileUrl(true); 00262 }
getTmpImage | ( | ) |
Definition at line 102 of file Image.php.
00103 { 00104 if(is_null($this->_image)) { 00105 $this->_tmpImage = $this->_getResource()->getTmpImage($this); 00106 } 00107 00108 return $this->_tmpImage; 00109 }
hasSpecialImage | ( | ) |
Definition at line 264 of file Image.php.
00265 { 00266 return $this->_getResource()->hasSpecialImage($this); 00267 }
setConfig | ( | Mage_Media_Model_Image_Config_Interface $ | config | ) |
Set media image config instance
Mage_Media_Model_Image_Config_Interface | $config |
Definition at line 77 of file Image.php.
setParam | ( | $ | param, | |
$ | value = null | |||
) |