getEntitiesToView($items, $langcode); // Early opt-out if the field is empty. if (empty($files)) { return $elements; } // Collect cache tags to be added for each item in the field. $video_items = array(); foreach ($files as $delta => $file) { $video_uri = $file->getFileUri(); $video_items[] = Url::fromUri(file_create_url($video_uri)); } $elements[] = array( '#theme' => 'videojs', '#items' => $video_items, '#player_attributes' => $this->getSettings(), '#attached' => array( 'library' => array('videojs/videojs'), ), ); return $elements; } /** * {@inheritdoc} */ public static function isApplicable(FieldDefinitionInterface $field_definition) { return $field_definition->isList(); } }