You are here

public function ImageEntityNormalizer::supportsNormalization in Consumer Image Styles 8

Same name and namespace in other branches
  1. 8.2 src/Normalizer/ImageEntityNormalizer.php \Drupal\consumer_image_styles\Normalizer\ImageEntityNormalizer::supportsNormalization()

Overrides NormalizerBase::supportsNormalization

File

src/Normalizer/ImageEntityNormalizer.php, line 81

Class

ImageEntityNormalizer

Namespace

Drupal\consumer_image_styles\Normalizer

Code

public function supportsNormalization($data, $format = NULL) {

  // It is very tricky to detect if a file entity is an image or not. This is
  // typically done using a special field type to point to this entity.
  // However we don't have access to that in here. Besides we want this to
  // apply when requesting a listing of file entities as well, not only via
  // includes. For all this we'll do string matching against the mimetype.
  return parent::supportsNormalization($data, $format) && strpos($data
    ->get('filemime')->value, 'image/') !== FALSE;
}