You are here

protected function Exif::setIfdEntries in File metadata manager 8.2

Same name and namespace in other branches
  1. 8 file_mdm_exif/src/Plugin/FileMetadata/Exif.php \Drupal\file_mdm_exif\Plugin\FileMetadata\Exif::setIfdEntries()

Adds or changes entries for an IFD.

Parameters

lsolesen\pel\PelIfd $ifd: A PelIfd object.

lsolesen\pel\PelEntry[] $entries: An array of PelEntry objects.

Return value

bool TRUE if entries were added/changed successfully, FALSE otherwise.

1 call to Exif::setIfdEntries()
Exif::doSaveMetadataToFile in file_mdm_exif/src/Plugin/FileMetadata/Exif.php
Saves metadata to file at URI.

File

file_mdm_exif/src/Plugin/FileMetadata/Exif.php, line 328

Class

Exif
FileMetadata plugin for EXIF.

Namespace

Drupal\file_mdm_exif\Plugin\FileMetadata

Code

protected function setIfdEntries(PelIfd $ifd, array $entries) {
  foreach ($entries as $tag => $input_entry) {
    if ($c = $ifd
      ->getEntry($tag)) {
      if ($input_entry === 'deleted') {
        unset($ifd[$tag]);
      }
      else {
        if ($this
          ->getFile() instanceof PelJpeg) {
          $c
            ->setValue($input_entry
            ->getValue());
        }
        else {
          $v = $input_entry
            ->getValue();
          if (is_array($v)) {
            $c
              ->setValueArray($v);
          }
          else {
            $c
              ->setValue($v);
          }
        }
      }
    }
    else {
      if ($input_entry !== 'deleted') {
        $ifd
          ->addEntry($input_entry);
      }
    }
  }
  return TRUE;
}