Detailed Description
ImageUtil provides support for image handling.
Definition at line 29 of file ImageUtil.php.
Static Public Member Functions | |
static | getImageTag ($imageFile, $widths, $type='w', $sizes='', $useDataAttributes=false, $alt='', $class='', $title='', array $data=[], $width=null, $fallbackFile='', $generate=false) |
static | getCachedImage ($location, $returnLocation=false, $callback=null) |
static | getCacheLocation ($imageFile, $width) |
static | invalidateCache ($imageFile) |
Public Attributes | |
const | IMAGE_CACHE_SECTION = 'images' |
Member Function Documentation
◆ getImageTag()
|
static |
Create an HTML image tag using srcset and sizes attributes.
The original image is supposed to be located inside the upload directory of the application (Media configuration section). The image locations in the srcset attribute will point to the frontend cache directory (FrontendCache configuration section).
- Parameters
-
$imageFile The image file location relative to the upload directory $widths Array of sorted width values to be used in the srcset attribute $type Indicates how width values should be used (optional, default: w) - w: Values will be used as pixels, e.g. widths="1600,960" results in srcset="... 1600w, ... 960w"
- x: Values will be used as pixel ration, e.g. widths="1600,960" results in srcset="... 2x, ... 1x"
$sizes String of media queries to define image size in relation of the viewport (optional) $useDataAttributes Boolean indicating whether to replace src, srcset, sizes by data-src, data-srcset, data-sizes (optional, default: false) $alt Alternative text (optional) $class Image class (optional) $title Image title (optional) $data Data attributes as key/value pairs $width Width in pixels to output for the width attribute, the height attribute will be calculated according to the aspect ration (optional) $fallbackFile The image file to use, if imageFile does not exist (optional) $generate Boolean indicating whether to generate the images or not (optional, default: false)
- Returns
- String
Definition at line 56 of file ImageUtil.php.
◆ getCachedImage()
|
static |
Output the cached image for the given cache location.
- Parameters
-
$location $returnLocation Boolean indicating if only the file location should be returned (optional) $callback Function called, after the cached image is created, receives the original and cached image as parameters (optional)
- Returns
- String, if returnLocation is true
Definition at line 160 of file ImageUtil.php.
◆ getCacheLocation()
|
static |
Get the cache location for the given image and width.
- Parameters
-
$imageFile Image file located inside the upload directory of the application given as path relative to WCMF_BASE $width
- Returns
- String
Definition at line 212 of file ImageUtil.php.
◆ invalidateCache()
|
static |
Delete the cached images for the given image file.
- Parameters
-
$imageFile Image file located inside the upload directory of the application given as path relative to WCMF_BASE
Definition at line 227 of file ImageUtil.php.
Member Data Documentation
◆ IMAGE_CACHE_SECTION
const IMAGE_CACHE_SECTION = 'images' |
Definition at line 31 of file ImageUtil.php.