Back to PhocacartImage class

Method getImageDisplay

public static
getImageDisplay
(mixed $image, mixed $imageAdditional, mixed $pathItem, mixed $switchImage, mixed $width, mixed $height, mixed $imageSize, mixed $layoutType, mixed $attributesOptions, mixed $attributesOptionsType = 1)

Method getImageDisplay - Source code

// posible feature request
/*
 *
 * Get ID key by attributes (when vender set default value of attribute in administration)
 *	$thinAttributes = PhocacartAttribute::getAttributesSelectedOnly($this->t['attr_options']);
 *	$idkey = PhocacartProduct::getProductKey($x->id, $thinAttributes);
 * When customer add the product with selected attributes to cart, the idkey is known
 *
public static function getImageChangedBySelectedAttributeAdvancedStockManagement($idKey, $imageSize) {
    // Ask jos_phocacart_product_stock table for image by product idKey



}
*/
// Image
// 1. Display default image
// 2. Store the information about default image into data-default-image because when we change images by selecting attributes
//    and at the end we deselect all the attributes, we should get back to default image
// 3. If there is some attribute option selected as default, display the image of this attribute options so the image will be
//    loaded at start
// But when we load an attribute image at start and user deselect attributes we need to go back to default image (we didn't load
// it in image src tag but we loaded it in data-default-image attribute
//
// Image2 is the image which is changed when hovering over image box
public static function getImageDisplay($image, $imageAdditional, $pathItem, $switchImage, $width, $height, $imageSize, $layoutType, $attributesOptions, $attributesOptionsType = 1)
{
    $imageA = array();
    if ($imageSize != '') {
        $imageA['size'] = $imageSize;
    } else {
        $imageA['size'] = $layoutType == 'gridlist' ? 'large' : 'medium';
    }
    $imageA['image'] = PhocacartImage::getThumbnailName($pathItem, $image, $imageA['size']);
    $imageA['default'] = $imageA['image'];
    if ($attributesOptionsType == 1) {
        // Default attributes - set by vendor in administration (default value of attributes)
        $imageAttributes = PhocaCartImage::getImageChangedByAttributes($attributesOptions, 'large');
    } else {
        // Selected attributes - selected by customer in e-shop - displayed e.g. in cart or checkout
        // the size is always large:
        // Attribute Image Large (normal image with small/medium/large thumbnails)
        // Attribute Image Small (small icon used e.g. for module or as click button)
        $imageAttributes = PhocaCartImage::getImageChangedBySelectedAttribute($attributesOptions, 'large');
    }
    if ($imageAttributes != '') {
        $imageA['image'] = PhocacartImage::getThumbnailName($pathItem, $imageAttributes, $imageA['size']);
    }
    $imageA['second'] = false;
    $imageA['phil'] = 'phIL-not-active';
    if ($switchImage == 1 && $imageAdditional != '') {
        $iAI = explode(',', $imageAdditional);
        if (isset($iAI[0]) && $iAI[0] != '') {
            $imageA['second'] = PhocacartImage::getThumbnailName($pathItem, $iAI[0], $imageA['size']);
            if (isset($imageA['second']->rel) && $imageA['second']->rel != '') {
                $imageA['phil'] = 'phIL';
            }
        }
    }
    $imageA['style'] = '';
    if (isset($width) && $width != '' && isset($height) && $height != '') {
        $imageA['style'] = 'style="width:' . $width . ';height:' . $height . '"';
    }
    if (!empty($imageA['image'])) {
        $imageA['image']->original = $image;
    }
    return $imageA;
}