You are here

public function Bynder::thumbnail in Bynder 8

Gets thumbnail image.

Media type plugin is responsible for returning URI of the generic thumbnail if no other is available. This functions should always return a valid URI.

Parameters

MediaInterface $media: Media.

Return value

string URI of the thumbnail.

Overrides MediaTypeInterface::thumbnail

File

src/Plugin/MediaEntity/Type/Bynder.php, line 307

Class

Bynder
Provides media type plugin for Bynder.

Namespace

Drupal\bynder\Plugin\MediaEntity\Type

Code

public function thumbnail(MediaInterface $media) {
  if ($thumbnail = $this
    ->getField($media, 'thumbnail_urls')) {
    if (isset($thumbnail['webimage'])) {
      if ($file = system_retrieve_file($thumbnail['webimage'], NULL, TRUE)) {
        return $file
          ->getFileUri();
      }
    }
  }
  return $this
    ->getDefaultThumbnail();
}