You are here

private function ExifContent::getImageFieldsMetadata in Exif 8

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

List fields that contains exif metadata.

Parameters

\Drupal\Core\Entity\FieldableEntityInterface $entity:

$ar_exif_fields:

$image_fields:

Return value

array|bool

Throws

\Drupal\Core\TypedData\Exception\MissingDataException

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

File

src/ExifContent.php, line 292

Class

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

Namespace

Drupal\exif

Code

private function getImageFieldsMetadata(FieldableEntityInterface $entity, &$ar_exif_fields, $image_fields) {
  $result = [];
  if (empty($ar_exif_fields)) {
    return TRUE;
  }
  if (empty($image_fields)) {
    return FALSE;
  }
  foreach ($ar_exif_fields as $drupal_field => $metadata_settings) {
    $field_image_name = $metadata_settings['image_field'];
    if (empty($image_fields[$field_image_name])) {
      $result[$field_image_name] = [];
    }
    else {
      $images_descriptor = $this
        ->getFileUriAndLanguage($entity, $field_image_name);
      if ($images_descriptor == FALSE) {
        $fullmetadata = [];
      }
      else {
        foreach ($images_descriptor as $index => $image_descriptor) {
          $fullmetadata[$index] = $this
            ->getDataFromFileUri($image_descriptor['uri']);
        }
      }
      $result[$field_image_name] = $fullmetadata;
      $ar_exif_fields[$drupal_field]['language'] = $image_descriptor['language'];
    }
  }
  return $result;
}