You are here

class MediaSource in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/src/Annotation/MediaSource.php \Drupal\media\Annotation\MediaSource
  2. 10 core/modules/media/src/Annotation/MediaSource.php \Drupal\media\Annotation\MediaSource

Defines a media source plugin annotation object.

Media sources are responsible for implementing all the logic for dealing with a particular type of media. They provide various universal and type-specific metadata about media of the type they handle.

Plugin namespace: Plugin\media\Source

For a working example, see \Drupal\media\Plugin\media\Source\File.

Hierarchy

Expanded class hierarchy of MediaSource

See also

\Drupal\media\MediaSourceInterface

\Drupal\media\MediaSourceBase

\Drupal\media\MediaSourceManager

hook_media_source_info_alter()

Plugin API

Related topics

1 file declares its use of MediaSource
MediaSourceManager.php in core/modules/media/src/MediaSourceManager.php
10 classes are annotated with MediaSource
AudioFile in core/modules/media/src/Plugin/media/Source/AudioFile.php
Media source wrapping around an audio file.
File in core/modules/media/src/Plugin/media/Source/File.php
File entity media source.
Image in core/modules/media/src/Plugin/media/Source/Image.php
Image entity media source.
OEmbed in core/modules/media/src/Plugin/media/Source/OEmbed.php
Provides a media source plugin for oEmbed resources.
Test in core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/Test.php
Provides test media source.

... See full list

File

core/modules/media/src/Annotation/MediaSource.php, line 26

Namespace

Drupal\media\Annotation
View source
class MediaSource extends Plugin {

  /**
   * The plugin ID.
   *
   * @var string
   */
  public $id;

  /**
   * The human-readable name of the media source.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $label;

  /**
   * A brief description of the media source.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $description = '';

  /**
   * The field types that can be used as a source field for this media source.
   *
   * @var string[]
   */
  public $allowed_field_types = [];

  /**
   * The classes used to define media source-specific forms.
   *
   * An array of form class names, keyed by ID. The ID represents the operation
   * the form is used for.
   *
   * @var string[]
   */
  public $forms = [];

  /**
   * A filename for the default thumbnail.
   *
   * The thumbnails are placed in the directory defined by the config setting
   * 'media.settings.icon_base_uri'. When using custom icons, make sure the
   * module provides a hook_install() implementation to copy the custom icons
   * to this directory. The media_install() function provides a clear example
   * of how to do this.
   *
   * @var string
   *
   * @see media_install()
   */
  public $default_thumbnail_filename = 'generic.png';

  /**
   * The metadata attribute name to provide the thumbnail URI.
   *
   * @var string
   */
  public $thumbnail_uri_metadata_attribute = 'thumbnail_uri';

  /**
   * (optional) The metadata attribute name to provide the thumbnail alt.
   *
   * "Thumbnail" will be used if the attribute name is not provided.
   *
   * @var string|null
   */
  public $thumbnail_alt_metadata_attribute;

  /**
   * (optional) The metadata attribute name to provide the thumbnail title.
   *
   * The name of the media item will be used if the attribute name is not
   * provided.
   *
   * @var string|null
   */
  public $thumbnail_title_metadata_attribute;

  /**
   * The metadata attribute name to provide the default name.
   *
   * @var string
   */
  public $default_name_metadata_attribute = 'default_name';

}

Members

Namesort descending Modifiers Type Description Overrides
MediaSource::$allowed_field_types public property The field types that can be used as a source field for this media source.
MediaSource::$default_name_metadata_attribute public property The metadata attribute name to provide the default name.
MediaSource::$default_thumbnail_filename public property A filename for the default thumbnail.
MediaSource::$description public property A brief description of the media source.
MediaSource::$forms public property The classes used to define media source-specific forms.
MediaSource::$id public property The plugin ID.
MediaSource::$label public property The human-readable name of the media source.
MediaSource::$thumbnail_alt_metadata_attribute public property (optional) The metadata attribute name to provide the thumbnail alt.
MediaSource::$thumbnail_title_metadata_attribute public property (optional) The metadata attribute name to provide the thumbnail title.
MediaSource::$thumbnail_uri_metadata_attribute public property The metadata attribute name to provide the thumbnail URI.
Plugin::$definition protected property The plugin definition read from the class annotation. 1
Plugin::get public function Gets the value of an annotation. Overrides AnnotationInterface::get 5
Plugin::getClass public function Gets the class of the annotated class. Overrides AnnotationInterface::getClass
Plugin::getId public function Gets the unique ID for this annotated class. Overrides AnnotationInterface::getId
Plugin::getProvider public function Gets the name of the provider of the annotated class. Overrides AnnotationInterface::getProvider 1
Plugin::parse protected function Parses an annotation into its definition.
Plugin::setClass public function Sets the class of the annotated class. Overrides AnnotationInterface::setClass
Plugin::setProvider public function Sets the name of the provider of the annotated class. Overrides AnnotationInterface::setProvider
Plugin::__construct public function Constructs a Plugin object. 2