You are here

public function Twitter::getMetadataAttributes in Media entity Twitter 8.2

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/Twitter.php, line 147

Class

Twitter
Twitter entity media source.

Namespace

Drupal\media_entity_twitter\Plugin\media\Source

Code

public function getMetadataAttributes() {
  $attributes = [
    'id' => $this
      ->t('Tweet ID'),
    'user' => $this
      ->t('Twitter user information'),
  ];
  if ($this->configuration['use_twitter_api']) {
    $attributes += [
      'image' => $this
        ->t('Link to the twitter image'),
      'image_local' => $this
        ->t('Copies tweet image to the local filesystem and returns the URI.'),
      'image_local_uri' => $this
        ->t('Gets URI of the locally saved image.'),
      'content' => $this
        ->t('This tweet content'),
      'retweet_count' => $this
        ->t('Retweet count for this tweet'),
      'profile_image_url_https' => $this
        ->t('Link to profile image'),
      'created_time' => $this
        ->t('Date/time created'),
      'user_name' => $this
        ->t('User name'),
    ];
  }
  return $attributes;
}