You are here

public function Instagram::getMetadataAttributes in Media entity Instagram 3.x

Same name and namespace in other branches
  1. 8.2 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 OEmbed::getMetadataAttributes

File

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

Class

Instagram
Implementation of an oEmbed Instagram source.

Namespace

Drupal\media_entity_instagram\Plugin\media\Source

Code

public function getMetadataAttributes() {
  return [
    'shortcode' => $this
      ->t('Instagram shortcode'),
    'type' => $this
      ->t('Resource type'),
    'author_name' => $this
      ->t('The name of the author/owner'),
    'default_name' => $this
      ->t('Default name of the media item'),
    'provider_name' => $this
      ->t("The name of the provider"),
    'provider_url' => $this
      ->t('The URL of the provider'),
    'thumbnail_uri' => $this
      ->t('Local URI of the thumbnail'),
    'thumbnail_width' => $this
      ->t('Thumbnail width'),
    'thumbnail_height' => $this
      ->t('Thumbnail height'),
    'width' => $this
      ->t('The width of the resource'),
    'html' => $this
      ->t('The HTML representation of the resource'),
  ];
}