Definition at line 32 of file Image.php.
__toString | ( | ) |
Definition at line 213 of file Image.php.
00214 { 00215 try { 00216 if( $this->getImageFile() ) { 00217 $this->_getModel()->setBaseFile( $this->getImageFile() ); 00218 } else { 00219 $this->_getModel()->setBaseFile( $this->getProduct()->getData($this->_getModel()->getDestinationSubdir()) ); 00220 } 00221 00222 if( $this->_getModel()->isCached() ) { 00223 return $this->_getModel()->getUrl(); 00224 } else { 00225 if( $this->_scheduleRotate ) { 00226 $this->_getModel()->rotate( $this->getAngle() ); 00227 } 00228 00229 if ($this->_scheduleResize) { 00230 $this->_getModel()->resize(); 00231 } 00232 00233 if( $this->_scheduleWatermark ) { 00234 $this->_getModel() 00235 ->setWatermarkPosition( $this->getWatermarkPosition() ) 00236 ->setWatermarkSize($this->parseSize($this->getWatermarkSize())) 00237 ->setWatermark($this->getWatermark(), $this->getWatermarkPosition()); 00238 } else { 00239 if( $watermark = Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_image") ) { 00240 $this->_getModel() 00241 ->setWatermarkPosition( $this->getWatermarkPosition() ) 00242 ->setWatermarkSize($this->parseSize($this->getWatermarkSize())) 00243 ->setWatermark($watermark, $this->getWatermarkPosition()); 00244 } 00245 } 00246 00247 $url = $this->_getModel()->saveFile()->getUrl(); 00248 } 00249 } catch( Exception $e ) { 00250 $url = Mage::getDesign()->getSkinUrl($this->getPlaceholder()); 00251 } 00252 return $url; 00253 }
_getModel | ( | ) | [protected] |
Enter description here...
Definition at line 271 of file Image.php.
_reset | ( | ) | [protected] |
Reset all previos data
Definition at line 49 of file Image.php.
00050 { 00051 $this->_model = null; 00052 $this->_scheduleResize = false; 00053 $this->_scheduleWatermark = false; 00054 $this->_scheduleRotate = false; 00055 $this->_angle = null; 00056 $this->_watermark = null; 00057 $this->_watermarkPosition = null; 00058 $this->_watermarkSize = null; 00059 $this->_product = null; 00060 $this->_imageFile = null; 00061 return $this; 00062 }
_setModel | ( | $ | model | ) | [protected] |
Enter description here...
Definition at line 260 of file Image.php.
backgroundColor | ( | $ | colorRGB | ) |
Set color to fill image frame with. Applicable before calling resize() The keepTransparency(true) overrides this (if image has transparent color) It is white by default.
array | $colorRGB |
Definition at line 172 of file Image.php.
00173 { 00174 // assume that 3 params were given instead of array 00175 if (!is_array($colorRGB)) { 00176 $colorRGB = func_get_args(); 00177 } 00178 $this->_getModel()->setBackgroundColor($colorRGB); 00179 return $this; 00180 }
constrainOnly | ( | $ | flag | ) |
Guarantee, that image picture will not be bigger, than it was. Applicable before calling resize() It is false by default
bool | $flag |
Definition at line 156 of file Image.php.
00157 { 00158 $this->_getModel()->setConstrainOnly($flag); 00159 return $this; 00160 }
getAngle | ( | ) | [protected] |
getImageFile | ( | ) | [protected] |
getOriginalHeigh | ( | ) |
getOriginalSizeArray | ( | ) |
Retrieve Original image size as array 0 - width, 1 - height
Definition at line 393 of file Image.php.
00394 { 00395 return array( 00396 $this->getOriginalWidth(), 00397 $this->getOriginalHeigh() 00398 ); 00399 }
getOriginalWidth | ( | ) |
getPlaceholder | ( | ) |
getProduct | ( | ) | [protected] |
getWatermark | ( | ) | [protected] |
getWatermarkPosition | ( | ) | [protected] |
Definition at line 304 of file Image.php.
00305 { 00306 if( $this->_watermarkPosition ) { 00307 return $this->_watermarkPosition; 00308 } else { 00309 return Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_position"); 00310 } 00311 }
getWatermarkSize | ( | ) | [protected] |
Definition at line 319 of file Image.php.
00320 { 00321 if( $this->_watermarkSize ) { 00322 return $this->_watermarkSize; 00323 } else { 00324 return Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_size"); 00325 } 00326 }
init | ( | Mage_Catalog_Model_Product $ | product, | |
$ | attributeName, | |||
$ | imageFile = null | |||
) |
Definition at line 64 of file Image.php.
00065 { 00066 $this->_reset(); 00067 $this->_setModel(Mage::getModel('catalog/product_image')); 00068 $this->_getModel()->setDestinationSubdir($attributeName); 00069 $this->setProduct($product); 00070 if ($imageFile) { 00071 $this->setImageFile($imageFile); 00072 } 00073 else { 00074 // add for work original size 00075 $this->_getModel()->setBaseFile( $this->getProduct()->getData($this->_getModel()->getDestinationSubdir()) ); 00076 } 00077 return $this; 00078 }
keepAspectRatio | ( | $ | flag | ) |
Guarantee, that image picture width/height will not be distorted. Applicable before calling resize() It is true by default.
bool | $flag |
Definition at line 106 of file Image.php.
00107 { 00108 $this->_getModel()->setKeepAspectRatio($flag); 00109 return $this; 00110 }
keepFrame | ( | $ | flag, | |
$ | position = array('center', 'middle') | |||
) |
Guarantee, that image will have dimensions, set in $width/$height Applicable before calling resize() Not applicable, if keepAspectRatio(false)
$position - TODO, not used for now - picture position inside the frame.
bool | $flag | |
array | $position |
Definition at line 124 of file Image.php.
00125 { 00126 $this->_getModel()->setKeepFrame($flag); 00127 return $this; 00128 }
keepTransparency | ( | $ | flag, | |
$ | alphaOpacity = null | |||
) |
Guarantee, that image will not lose transparency if any. Applicable before calling resize() It is true by default.
$alphaOpacity - TODO, not used for now
bool | $flag | |
int | $alphaOpacity |
Definition at line 142 of file Image.php.
00143 { 00144 $this->_getModel()->setKeepTransparency($flag); 00145 return $this; 00146 }
parseSize | ( | $ | string | ) | [protected] |
Enter description here...
Definition at line 355 of file Image.php.
00356 { 00357 $size = explode('x', strtolower($string)); 00358 if( sizeof($size) == 2 ) { 00359 return array( 00360 'width' => ($size[0] > 0) ? $size[0] : null, 00361 'heigth' => ($size[1] > 0) ? $size[1] : null, 00362 ); 00363 } 00364 return false; 00365 }
placeholder | ( | $ | fileName | ) |
resize | ( | $ | width, | |
$ | height = null | |||
) |
Schedule resize of the image $width *or* $height can be null - in this case, lacking dimension will be calculated.
int | $width | |
int | $height |
Definition at line 89 of file Image.php.
00090 { 00091 $this->_getModel()->setWidth($width)->setHeight($height); 00092 $this->_scheduleResize = true; 00093 return $this; 00094 }
rotate | ( | $ | angle | ) |
setAngle | ( | $ | angle | ) | [protected] |
setImageFile | ( | $ | file | ) | [protected] |
setProduct | ( | $ | product | ) | [protected] |
setWatermark | ( | $ | watermark | ) | [protected] |
setWatermarkPosition | ( | $ | position | ) | [protected] |
setWatermarkSize | ( | $ | size | ) |
watermark | ( | $ | fileName, | |
$ | position, | |||
$ | size = null | |||
) |
Definition at line 190 of file Image.php.
00191 { 00192 $this->setWatermark($fileName) 00193 ->setWatermarkPosition($position) 00194 ->setWatermarkSize($size); 00195 $this->_scheduleWatermark = true; 00196 return $this; 00197 }