protected function Base64ImageFormatter::getImageStyleUri in Entity Print 8.2
Gets the image style uri.
@TODO We should use ImageStyleDownloadController once core is fixed. Currently this code does not acquire a look to generate the derivative and may cause issues on high traffic sites with multiple web heads.
Parameters
\Drupal\image\Entity\ImageStyle $image_style: The image style we want a URL for.
\Drupal\file\Entity\File $file: The file object.
Return value
bool|string A uri for this image style.
See also
https://drupal.org/node/1220116
1 call to Base64ImageFormatter::getImageStyleUri()
- Base64ImageFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ Base64ImageFormatter.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ Base64ImageFormatter.php, line 91
Class
- Base64ImageFormatter
- Plugin implementation of the 'entity_print_base64_image_formatter' formatter.
Namespace
Drupal\entity_print\Plugin\Field\FieldFormatterCode
protected function getImageStyleUri(ImageStyle $image_style, File $file) {
$file_uri = $file
->getFileUri();
$image_style_uri = $image_style
->buildUri($file_uri);
if (file_exists($image_style_uri) || $image_style
->createDerivative($file_uri, $image_style_uri)) {
return $image_style_uri;
}
return FALSE;
}