VideoFile.php
Same filename in other branches
Namespace
Drupal\media\Plugin\media\SourceFile
-
core/
modules/ media/ src/ Plugin/ media/ Source/ VideoFile.php
View source
<?php
namespace Drupal\media\Plugin\media\Source;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\media\Attribute\MediaSource;
use Drupal\media\MediaTypeInterface;
/**
* Media source wrapping around a video file.
*
* @see \Drupal\file\FileInterface
*/
class VideoFile extends File {
/**
* {@inheritdoc}
*/
public function createSourceField(MediaTypeInterface $type) {
return parent::createSourceField($type)->set('settings', [
'file_extensions' => 'mp4',
]);
}
/**
* {@inheritdoc}
*/
public function prepareViewDisplay(MediaTypeInterface $type, EntityViewDisplayInterface $display) {
$display->setComponent($this->getSourceFieldDefinition($type)
->getName(), [
'type' => 'file_video',
'label' => 'visually_hidden',
]);
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
VideoFile | Media source wrapping around a video file. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.