You are here

public function ImageStylesProvider::entityIsImage in Consumer Image Styles 8.3

Same name and namespace in other branches
  1. 4.x src/ImageStylesProvider.php \Drupal\consumer_image_styles\ImageStylesProvider::entityIsImage()

Checks if an entity is an image.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity.

Return value

bool TRUE if the entity is an image.

File

src/ImageStylesProvider.php, line 100

Class

ImageStylesProvider
Class ImageStylesProvider.

Namespace

Drupal\consumer_image_styles

Code

public function entityIsImage(EntityInterface $entity) {
  if (!$entity instanceof File) {
    return FALSE;
  }
  return $this->imageFactory
    ->get($entity
    ->getFileUri())
    ->isValid();
}