You are here

private static function oEmbedThumbnail::oembed_pre_render_image_helper in oEmbed 8

1 call to oEmbedThumbnail::oembed_pre_render_image_helper()
oEmbedThumbnail::preRenderThumbnail in src/Element/oEmbedThumbnail.php

File

src/Element/oEmbedThumbnail.php, line 52

Class

oEmbedThumbnail
Class oEmbedThumbnail @package Drupal\oembed\Render\Element

Namespace

Drupal\oembed\Element

Code

private static function oembed_pre_render_image_helper(&$element) {

  /** @var \Bangpound\oEmbed\Response\Response $embed */
  $embed = $element['#embed'];
  $element['#uri'] = $embed
    ->getThumbnailUrl();
  $element['#alt'] = oembed_alt_attr($embed);
  $element['#title'] = $embed
    ->getTitle();
  $element['#height'] = !empty($embed
    ->getThumbnailHeight()) ? $embed
    ->getThumbnailHeight() : NULL;
  $element['#width'] = !empty($embed
    ->getThumbnailWidth()) ? $embed
    ->getThumbnailWidth() : NULL;

  // theme_image() prefers width, height, alt and title element properties over
  // attributes so we manually override them if an associated attribute is set.
  foreach (array(
    'width',
    'height',
    'alt',
    'title',
  ) as $key) {
    if (isset($element['#attributes'][$key])) {
      $element['#' . $key] = $element['#attributes'][$key];
    }
  }
}