You are here

public function Instagram::getMetadataAttributes in Media entity Instagram 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/media/Source/Instagram.php \Drupal\media_entity_instagram\Plugin\media\Source\Instagram::getMetadataAttributes()

Gets a list of metadata attributes provided by this plugin.

Most media sources have associated metadata, describing attributes such as:

  • dimensions
  • duration
  • encoding
  • date
  • location
  • permalink
  • licensing information
  • ...

This method should list all metadata attributes that a media source MAY offer. In other words: it is possible that a particular media item does not contain a certain attribute. For example: an oEmbed media source can contain both video and images. Images don't have a duration, but videos do.

(The term 'attributes' was chosen because it cannot be confused with 'fields' and 'properties', both of which are concepts in Drupal's Entity Field API.)

Return value

array Associative array with:

  • keys: metadata attribute names
  • values: human-readable labels for those attribute names

Overrides MediaSourceInterface::getMetadataAttributes

File

src/Plugin/media/Source/Instagram.php, line 113

Class

Instagram
Provides media type plugin for Instagram.

Namespace

Drupal\media_entity_instagram\Plugin\media\Source

Code

public function getMetadataAttributes() {
  return [
    'shortcode' => $this
      ->t('Instagram shortcode'),
    'id' => $this
      ->t('Media ID'),
    'type' => $this
      ->t('Media type: image or video'),
    'thumbnail' => $this
      ->t('Link to the thumbnail'),
    'thumbnail_local' => $this
      ->t("Copies thumbnail locally and return it's URI"),
    'thumbnail_local_uri' => $this
      ->t('Returns local URI of the thumbnail'),
    'username' => $this
      ->t('Author of the post'),
    'caption' => $this
      ->t('Caption'),
  ];
}