function template_preprocess_image_style
Prepares variables for image style templates.
Default template: image-style.html.twig.
Parameters
array $variables: An associative array containing:
- width: The width of the image.
- height: The height of the image.
- style_name: The name of the image style to be applied.
- uri: URI of the source image before styling.
- alt: The alternative text for text-based browsers. HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft allows the alt attribute to be omitted in some cases. Therefore, this variable defaults to an empty string, but can be set to NULL for the attribute to be omitted. Usually, neither omission nor an empty string satisfies accessibility requirements, so it is strongly encouraged for code using '#theme' => 'image_style' to pass a meaningful value for this variable.
- title: The title text is displayed when the image is hovered in some popular browsers.
- attributes: Associative array of additional attributes to be placed in the img tag.
Deprecated
in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme().
See also
https://www.drupal.org/node/3504125
File
-
core/
modules/ image/ image.module, line 84
Code
function template_preprocess_image_style(&$variables) : void {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED);
\Drupal::service(ImageThemeHooks::class)->preprocessImageStyle($variables);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.