You are here

private function FileAndImageTableFormatter::isImage in Open Social 8.9

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

Check if its a file or image so we know what to render.

Parameters

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

Return value

bool TRUE when it's an image and not a file

1 call to FileAndImageTableFormatter::isImage()
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 72

Class

FileAndImageTableFormatter
Plugin implementation of the 'file_image_default' formatter.

Namespace

Drupal\social_comment_upload\Plugin\Field\FieldFormatter

Code

private function isImage(FileInterface $file) {
  $image = $this
    ->getImage($file);
  if ($image === NULL) {
    return FALSE;
  }
  return $image
    ->isValid();
}