public function AssetImageHelper::getThumbnail in Media: Acquia DAM 8
Get the thumbnail for the given asset.
Parameters
\cweagans\webdam\Entity\Asset $asset: The Acquia DAM asset.
\Drupal\file\FileInterface|false $file: The file entity to create a thumbnail uri from.
Return value
string|false The image URI to use or FALSE.
File
- src/
Service/ AssetImageHelper.php, line 165
Class
- AssetImageHelper
- Class AssetImageHelper.
Namespace
Drupal\media_acquiadam\ServiceCode
public function getThumbnail(Asset $asset, $file = FALSE) {
if (empty($file) || !$file instanceof FileInterface) {
return $this
->getFallbackThumbnail();
}
$mimetype = $this
->getMimeTypeFromFileType($asset->filetype);
$is_image = 'image' == $mimetype['discrete'];
$thumbnail = $is_image ? $this
->getImageThumbnail($file) : $this
->getGenericMediaIcon($mimetype);
return !empty($thumbnail) ? $thumbnail : $this
->getFallbackThumbnail();
}