ImageUtil.php
43 * - w: Values will be used as pixels, e.g. widths="1600,960" results in srcset="... 1600w, ... 960w"
44 * - x: Values will be used as pixel ration, e.g. widths="1600,960" results in srcset="... 2x, ... 1x"
45 * @param $sizes String of media queries to define image size in relation of the viewport (optional)
46 * @param $useDataAttributes Boolean indicating whether to replace src, srcset, sizes by data-src, data-srcset, data-sizes (optional, default: __false__)
51 * @param $width Width in pixels to output for the width attribute, the height attribute will be calculated according to the aspect ration (optional)
53 * @param $generate Boolean indicating whether to generate the images or not (optional, default: __false__)
57 $useDataAttributes=false, $alt='', $class='', $title='', array $data=[], $width=null, $fallbackFile='',
123 $srcset[] = FileUtil::urlencodeFilename($resizedFile).' '.($type === 'w' ? $curWidth.'w' : ($count-$i).'x');
134 $tag = '<img '.($useDataAttributes ? 'data-' : '').'src="'.FileUtil::urlencodeFilename($imageFile).'" alt="'.$alt.'"'.
156 * @param $returnLocation Boolean indicating if only the file location should be returned (optional)
157 * @param $callback Function called, after the cached image is created, receives the original and cached image as parameters (optional)
195 $file = FileUtil::fileExists($resizedFile) ? $resizedFile : (FileUtil::fileExists($sourceFile) ? $sourceFile : null);
208 * @param $imageFile Image file located inside the upload directory of the application given as path relative to WCMF_BASE
static getCachedImage($location, $returnLocation=false, $callback=null)
Output the cached image for the given cache location.
Definition: ImageUtil.php:160
static getFiles($directory, $pattern='/./', $prependDirectoryName=false, $recursive=false)
Definition: FileUtil.php:98
static getCacheLocation($imageFile, $width)
Get the cache location for the given image and width.
Definition: ImageUtil.php:212
static basename($file)
Get the trailing name component of a path (locale independent)
Definition: FileUtil.php:327
static getImageTag($imageFile, $widths, $type='w', $sizes='', $useDataAttributes=false, $alt='', $class='', $title='', array $data=[], $width=null, $fallbackFile='', $generate=false)
Create an HTML image tag using srcset and sizes attributes.
Definition: ImageUtil.php:56
ConfigurationException signals an exception in the configuration.
Definition: ConfigurationException.php:18
static invalidateCache($imageFile)
Delete the cached images for the given image file.
Definition: ImageUtil.php:227
static getInstance($name, $dynamicConfiguration=[])
Definition: ObjectFactory.php:47
static realpath($path)
Realpath function that also works for non existing paths code from http://www.php....
Definition: FileUtil.php:244
ObjectFactory implements the service locator pattern by wrapping a Factory instance and providing sta...
Definition: ObjectFactory.php:24
static fixFilename($file)
Fix the name of an existing file to be used with php file functions.
Definition: FileUtil.php:286
static makeRelative($absUri, $base)
Convert an absolute URI to a relative code from http://www.webmasterworld.com/forum88/334....
Definition: URIUtil.php:27