drupal 8 image filtre code example

Example 1: drupal 8 theme image render array

$image_variables = [
  '#theme' => 'image',
  '#uri' => $value['snippet']['thumbnails']['default']['url'],
  '#alt' => $title,
  '#title' => $title,
  '#width' => $width,
];

$image_variables = [
  '#theme' => 'image_style',
  '#uri' => $value['snippet']['thumbnails']['default']['url'],
  '#alt' => $title,
  '#title' => $title,
  '#width' => $width,
  '#style_name' => $image_style,
];

Example 2: drupal 8 get media image uri

$image_url = $media->field_media_image->entity->getFileUri();
file_create_url($image_url);

Tags:

Misc Example