Detailed Description

ImageUtil provides support for image handling.

ingo herwig

Definition at line 29 of file ImageUtil.php.

Static Public Member Functions

static getImageTag ($imageFile, $widths, $type='w', $sizes='', $useDataAttributes=false, $alt='', $class='', $title='', $width=null, $fallbackFile='', $generate=false)
static getCachedImage ($location)

Public Attributes

const IMAGE_CACHE_SECTION = 'images'

Member Function Documentation

◆ getImageTag()

static getImageTag (   $imageFile,
  $type = 'w',
  $sizes = '',
  $useDataAttributes = false,
  $alt = '',
  $class = '',
  $title = '',
  $width = null,
  $fallbackFile = '',
  $generate = false 

Create an HTML image tag using srcset and sizes attributes.

The image locations in the srcset attribute will point to the frontend cache directory (FrontendCache configuration section).

$imageFileThe image file
$widthsArray of sorted width values to be used in the srcset attribute
$typeIndicates 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"
$sizesString of media queries to define image size in relation of the viewport (optional)
$useDataAttributesBoolean indicating whether to replace src, srcset, sizes by data-src, data-srcset, data-sizes (optional, default: false)
$altAlternative text (optional)
$classImage class (optional)
$titleImage title (optional)
$widthWidth in pixels to output for the width attribute, the height attribute will be calculated according to the aspect ration (optional)
$fallbackFileThe image file to use, if imageFile does not exist (optional)
$generateBoolean indicating whether to generate the images or not (optional, default: false)

Definition at line 54 of file ImageUtil.php.

◆ getCachedImage()

static getCachedImage (   $location)

Output the cached image for the given cache location.


Definition at line 137 of file ImageUtil.php.

Member Data Documentation


const IMAGE_CACHE_SECTION = 'images'

Definition at line 31 of file ImageUtil.php.