OXID eShop CE  6.1.5
OxidEsales\EshopCommunity\Core\DynamicImageGenerator Class Reference
+ Collaboration diagram for OxidEsales\EshopCommunity\Core\DynamicImageGenerator:

Public Member Functions

 __call ($method, $args)
 
 getImagePath ($absPath=false)
 
 outputImage ()
 

Static Public Member Functions

static getInstance ()
 

Protected Member Functions

 _getShopBasePath ()
 
 _getImageUri ()
 
 _getImageName ()
 
 _getImageMasterPath ()
 
 _getImageInfo ()
 
 _getImageTarget ()
 
 _getNopicImageTarget ()
 
 _getImageType ()
 
 _generatePng ($source, $target, $width, $height)
 
 _generateJpg ($source, $target, $width, $height, $quality)
 
 _generateGif ($source, $target, $width, $height)
 
 _isTargetPathValid ($path)
 
 _createFolders ($dir)
 
 _isValidPath ($path)
 
 _generateImage ($imageSource, $imageTarget)
 
 _getLockName ($name)
 
 _lock ($source)
 
 _unlock ($source)
 
 validateImageFileExtension ($fileExtension)
 
 _setHeader ($header)
 
 _getHeaders ()
 
 validateGdVersion ()
 
 validateFileExist ($filePath)
 
 getImageDimensions ($imageFilePath)
 

Protected Attributes

 $_aHeaders = []
 
 $_aAllowedImgTypes = ["jpg", "jpeg", "png", "gif"]
 
 $_sImageInfoSep = "_"
 
 $_hLockHandle = null
 
 $_sImageUri = null
 
 $_aConfParamToPath
 

Static Protected Attributes

static $_oInstance = null
 

Detailed Description

Image generator class

Member Function Documentation

◆ __call()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::__call (   $method,
  $args 
)

Only used for convenience in UNIT tests by doing so we avoid writing extended classes for testing protected or private methods

Parameters
string$methodMethods name
array$argsArgument array
Exceptions

◆ _createFolders()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_createFolders (   $dir)
protected

Checks if valid and creates missing needed folders

Parameters
string$dirfolder(s) to create
Returns
bool

◆ _generateGif()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_generateGif (   $source,
  $target,
  $width,
  $height 
)
protected

Generates GIF type image and returns its location on file system

Parameters
string$sourceimage source
string$targetimage target
int$widthimage width
int$heightimage height
Returns
string

◆ _generateImage()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_generateImage (   $imageSource,
  $imageTarget 
)
protected

Converts a given source image into a target image

Parameters
string$imageSourceFile path of the source image
string$imageTargetFile path of the image to be generated
Exceptions
OxidEsales

◆ _generateJpg()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_generateJpg (   $source,
  $target,
  $width,
  $height,
  $quality 
)
protected

Generates JPG type image and returns its location on file system

Parameters
string$sourceimage source
string$targetimage target
int$widthimage width
int$heightimage height
int$qualitynew image quality
Returns
string

◆ _generatePng()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_generatePng (   $source,
  $target,
  $width,
  $height 
)
protected

Generates PNG type image and returns its location on file system

Parameters
string$sourceimage source
string$targetimage target
int$widthimage width
int$heightimage height
Returns
string

◆ _getHeaders()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_getHeaders ( )
protected

Return headers array

Returns
array

◆ _getImageInfo()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_getImageInfo ( )
protected

Returns image info array

Returns
array

◆ _getImageMasterPath()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_getImageMasterPath ( )
protected

Returns path to possible master image

Returns
string

◆ _getImageName()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_getImageName ( )
protected

Returns requested image name

Returns
string

◆ _getImageTarget()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_getImageTarget ( )
protected

Returns full requested image path on file system

Returns
string

◆ _getImageType()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_getImageType ( )
protected

Returns image type used for image generation and header setting

Returns
string

◆ _getImageUri()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_getImageUri ( )
protected

Returns requested image uri

Returns
string

◆ _getLockName()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_getLockName (   $name)
protected

Returns lock file name

Parameters
string$nameoriginal file name
Returns
string

◆ _getNopicImageTarget()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_getNopicImageTarget ( )
protected

Nopic image path

Returns
string

◆ _getShopBasePath()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_getShopBasePath ( )
protected

Returns shops base path

Returns
string

◆ _isTargetPathValid()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_isTargetPathValid (   $path)
protected

Checks if requested image path is valid. If path is valid but is not created - creates directory structure

Parameters
string$pathimage path name to check
Returns
bool

◆ _isValidPath()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_isValidPath (   $path)
protected

Checks if main folder matches requested

Parameters
string$pathimage path name to check
Returns
bool

◆ _lock()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_lock (   $source)
protected

Locks file and returns locking state

Parameters
string$sourcesource file which should be locked
Returns
bool

◆ _setHeader()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_setHeader (   $header)
protected

Custom header setter

Parameters
string$headerheader

◆ _unlock()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::_unlock (   $source)
protected

Deletes lock file

Parameters
string$sourcesource file which should be locked

◆ getImageDimensions()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::getImageDimensions (   $imageFilePath)
protected

Return an array with the dimensions (width x height) of an image file. returns array (0,0), if the dimensions could not be retrieved.

Parameters
string$imageFilePath
Returns
array

◆ getImagePath()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::getImagePath (   $absPath = false)

Returns the file path of an image as requested by self::_getImageUri(). If the requested image does not exist, if will be rendered from the master image. If the master image does not exist, a nopic image in the same directory as the requested image is shown. If the nopic image does not exist, it will be generated in with the same dimensions and quality as the requested image. If the nopic image does not exist, the method returns false.

Parameters
bool$absPathabsolute requested image path (not url, but real path on file system)
Returns
string|false

◆ getInstance()

static OxidEsales\EshopCommunity\Core\DynamicImageGenerator::getInstance ( )
static

Creates and returns picture generator instance

Returns
DynamicImageGenerator

◆ outputImage()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::outputImage ( )

Creates and outputs requested image. If source file was not found - tries to render related "nopic.jpg". If "nopic.jpg" is not available - sends 404 header to browser

◆ validateFileExist()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::validateFileExist (   $filePath)
protected

Return true, if a given file path exists.

Parameters
string$filePath
Returns
bool

◆ validateGdVersion()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::validateGdVersion ( )
protected

Return true, if the version of the gd library is correct

Returns
bool

◆ validateImageFileExtension()

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::validateImageFileExtension (   $fileExtension)
protected
Parameters
string$fileExtensionExtension to be validated. Validation is case insensitive.
Returns
bool

Member Data Documentation

◆ $_aAllowedImgTypes

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::$_aAllowedImgTypes = ["jpg", "jpeg", "png", "gif"]
protected

◆ $_aConfParamToPath

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::$_aConfParamToPath
protected
Initial value:
= [
"sIconsize" => '/.*\/generated\/product\/(icon|\d+)\/\d+\_\d+\_\d+$/',
"sThumbnailsize" => '/.*\/generated\/product\/(thumb|\d+)\/\d+\_\d+\_\d+$/',
"sZoomImageSize" => '/.*\/generated\/product\/\d+\/\d+\_\d+\_\d+$/',
"aDetailImageSizes" => '/.*\/generated\/product\/\d+\/\d+\_\d+\_\d+$/',
"sManufacturerIconsize" => '/.*\/generated\/(manufacturer|vendor)\/icon\/\d+\_\d+\_\d+$/',
"sCatThumbnailsize" => '/.*\/generated\/category\/thumb\/\d+\_\d+\_\d+$/',
"sCatIconsize" => '/.*\/generated\/category\/icon\/\d+\_\d+\_\d+$/',
"sCatPromotionsize" => '/.*\/generated\/category\/promo_icon\/\d+\_\d+\_\d+$/'
]

◆ $_aHeaders

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::$_aHeaders = []
protected

◆ $_hLockHandle

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::$_hLockHandle = null
protected

◆ $_oInstance

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::$_oInstance = null
staticprotected

◆ $_sImageInfoSep

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::$_sImageInfoSep = "_"
protected

◆ $_sImageUri

OxidEsales\EshopCommunity\Core\DynamicImageGenerator::$_sImageUri = null
protected

The documentation for this class was generated from the following file: