00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Catalog_Model_Product_Attribute_Frontend_Image extends Mage_Eav_Model_Entity_Attribute_Frontend_Abstract
00036 {
00037
00038 public function getUrl($object, $size=null)
00039 {
00040 $url = false;
00041 $image = $object->getData($this->getAttribute()->getAttributeCode());
00042
00043 if( !is_null($size) && file_exists(Mage::getBaseDir('media').DS.'catalog'.DS.'product'.DS.$size.DS.$image) ) {
00044 # resized image is cached
00045 $url = Mage::app()->getStore($object->getStore())->getBaseUrl('media').'catalog/product/' . $size . '/' . $image;
00046 } elseif( !is_null($size) ) {
00047 # resized image is not cached
00048 $url = Mage::app()->getStore($object->getStore())->getBaseUrl().'catalog/product/image/size/' . $size . '/' . $image;
00049 } elseif ($image) {
00050 # using original image
00051 $url = Mage::app()->getStore($object->getStore())->getBaseUrl('media').'catalog/product/'.$image;
00052 }
00053 return $url;
00054 }
00055
00056 }