Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
   eZ Publish 4.x / legacy

eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Skip to end of metadata
Go to start of metadata


ez_image_alias() is a Twig helper that lets you display a selected variant (alias) of an image.

Prototype and Arguments

ez_image_alias( eZ\Publish\API\Repository\Values\Content\Field field, eZ\Publish\Core\Repository\Values\Content\VersionInfo versionInfo, string variantName )

Argument nameTypeDescription
fieldeZ\Publish\API\Repository\Values\Content\FieldThe image Field
versionInfoeZ\Publish\Core\Repository\Values\Content\VersionInfoThe VersionInfo that the field belongs to
variantNamestringName of the image alias to be used
  • No labels

1 Comment

  1. Unknown User (remy_php)


    {% set variation = ez_image_alias( ez_field(content, "cover"), content.versionInfo, "large")  %}
    {{ variation.uri }}


    But in eZ 5.4.5 there is no ez_field Twig helper

    It can be easily added


    public function getFunctions() {
    return array(
    'my_ez_field' => new \Twig_Function_Method( $this, 'my_ez_field' ),
    public function bfm_ez_field(Content $content, $fieldDefIdentifier) {
    $fields = $content->getFields();
    foreach ($fields as $field) {
    if ($field->fieldDefIdentifier === $fieldDefIdentifier) {
    return $field;
    throw new \Exception("Le field $fieldDefIdentifier n'existe pas dans le content {$content->id}");

    {% set variation = ez_image_alias( my_ez_field(content, "cover"), content.versionInfo, "large")  %}
    {{ variation.uri }}