You are here

public function AssetImageHelper::getImageThumbnail in Media: Acquia DAM 8

Get an image path from a file.

Parameters

\Drupal\file\FileInterface $file: The image file to get the image path for.

Return value

false|string The image path to use or FALSE on failure.

1 call to AssetImageHelper::getImageThumbnail()
AssetImageHelper::getThumbnail in src/Service/AssetImageHelper.php
Get the thumbnail for the given asset.

File

src/Service/AssetImageHelper.php, line 306

Class

AssetImageHelper
Class AssetImageHelper.

Namespace

Drupal\media_acquiadam\Service

Code

public function getImageThumbnail(FileInterface $file) {

  /** @var \Drupal\Core\Image\Image $image */
  $image = $this->imageFactory
    ->get($file
    ->getFileUri());
  if ($image
    ->isValid()) {

    // Pre-create all image styles.
    $styles = ImageStyle::loadMultiple();
    foreach ($styles as $style) {

      /** @var \Drupal\image\Entity\ImageStyle $style */
      $style
        ->flush($file
        ->getFileUri());
    }
    return $file
      ->getFileUri();
  }
  return FALSE;
}