You are here

private function ExifContent::getImageFields in Exif 8

Same name and namespace in other branches
  1. 8.2 src/ExifContent.php \Drupal\exif\ExifContent::getImageFields()

Look for image fields in an entity type.

Parameters

\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity to look for image fields.

Return value

array the list of image fields found in the entity

1 call to ExifContent::getImageFields()
ExifContent::entity_insert_update in src/ExifContent.php
Main entry of the module.

File

src/ExifContent.php, line 267

Class

ExifContent
Class ExifContent make link between drupal content and file content.

Namespace

Drupal\exif

Code

private function getImageFields(FieldableEntityInterface $entity) {
  $result = [];
  if ($entity
    ->getEntityTypeId() == 'node' or $entity
    ->getEntityTypeId() == 'media') {
    foreach ($entity
      ->getFieldDefinitions() as $fieldName => $fieldDefinition) {
      if ($fieldDefinition
        ->getType() == 'image') {
        $result[$fieldName] = $fieldDefinition;
      }
    }
  }
  if ($entity
    ->getEntityTypeId() == 'file') {
    $result['file'] = $entity;
  }
  return $result;
}