You are here

public function ImgData::getElementMap in Panopoly 8.2

Provides a mapping of form elements to IPTC data.

@todo add persistent caching.

Parameters

string $entityType: The entity type that the widget is placed on.

Return value

array The form element map.

File

modules/panopoly/panopoly_media/src/ImgData.php, line 95

Class

ImgData
Reads IPTC image data.

Namespace

Drupal\panopoly_media

Code

public function getElementMap($entityType) {
  if (!isset($this->elementMap[$entityType])) {
    $map = [
      'name' => [
        'iptc' => 'name',
        'formElement' => [
          'name',
          0,
          'value',
        ],
      ],
      'alt' => [
        'iptc' => 'headline',
        'element' => [
          'alt',
        ],
      ],
      'description' => [
        'iptc' => 'caption',
        'formElement' => [
          'field_panopoly_media_description',
          0,
          'value',
        ],
      ],
    ];
    \Drupal::moduleHandler()
      ->alter('panopoly_media_iptc_mapping', $map, $entityType);
    $this->elementMap[$entityType] = $map;
  }
  return $this->elementMap[$entityType];
}