You are here

private function FileAndImageTableFormatter::getImage in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_comment_upload/src/Plugin/Field/FieldFormatter/FileAndImageTableFormatter.php \Drupal\social_comment_upload\Plugin\Field\FieldFormatter\FileAndImageTableFormatter::getImage()
  2. 8.5 modules/social_features/social_comment_upload/src/Plugin/Field/FieldFormatter/FileAndImageTableFormatter.php \Drupal\social_comment_upload\Plugin\Field\FieldFormatter\FileAndImageTableFormatter::getImage()
  3. 8.6 modules/social_features/social_comment_upload/src/Plugin/Field/FieldFormatter/FileAndImageTableFormatter.php \Drupal\social_comment_upload\Plugin\Field\FieldFormatter\FileAndImageTableFormatter::getImage()
  4. 8.7 modules/social_features/social_comment_upload/src/Plugin/Field/FieldFormatter/FileAndImageTableFormatter.php \Drupal\social_comment_upload\Plugin\Field\FieldFormatter\FileAndImageTableFormatter::getImage()

Grab the Image if we are dealing with one.

Parameters

\Drupal\file\FileInterface $file: A file entity. This function may resize the file affecting its size.

Return value

\Drupal\Core\Image\ImageInterface An Image object.

2 calls to FileAndImageTableFormatter::getImage()
FileAndImageTableFormatter::isImage in modules/social_features/social_comment_upload/src/Plugin/Field/FieldFormatter/FileAndImageTableFormatter.php
Check if its a file or image so we know what to render.
FileAndImageTableFormatter::viewElements in modules/social_features/social_comment_upload/src/Plugin/Field/FieldFormatter/FileAndImageTableFormatter.php
Builds a renderable array for a field value.

File

modules/social_features/social_comment_upload/src/Plugin/Field/FieldFormatter/FileAndImageTableFormatter.php, line 91

Class

FileAndImageTableFormatter
Plugin implementation of the 'file_image_default' formatter.

Namespace

Drupal\social_comment_upload\Plugin\Field\FieldFormatter

Code

private function getImage(FileInterface $file) {

  // Make sure we deal with a file.
  $image_factory = \Drupal::service('image.factory');
  return $image_factory
    ->get($file
    ->getFileUri());
}