Same name in other branches
  1. 8.x-1.x src/ExifContent.php \Drupal\exif\ExifContent::getImageFields()

Look for image fields in an entity type.

Paramètres

\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 dans src/ExifContent.php
Main entry of the module.

Fichier

src/ExifContent.php, line 276

Classe

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' || $entity->getEntityTypeId() == 'photos_image') {
        foreach ($entity->getFieldDefinitions() as $fieldName => $fieldDefinition) {
            if (in_array($fieldDefinition->getType(), [
                'image',
                'file',
            ])) {
                $result[$fieldName] = $fieldDefinition;
            }
        }
    }
    if ($entity->getEntityTypeId() == 'file') {
        $result['file'] = $entity;
    }
    return $result;
}