Same name and namespace in other branches
  1. 8.9.x core/modules/media/src/Annotation/MediaSource.php \Drupal\media\Annotation\MediaSource
  2. 9 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

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';

  /**
   * The metadata attribute name to provide the thumbnail width.
   *
   * @var string
   */
  public $thumbnail_width_metadata_attribute = 'thumbnail_width';

  /**
   * The metadata attribute name to provide the thumbnail height.
   *
   * @var string
   */
  public $thumbnail_height_metadata_attribute = 'thumbnail_height';

  /**
   * (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_height_metadata_attribute public property The metadata attribute name to provide the thumbnail height.
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.
MediaSource::$thumbnail_width_metadata_attribute public property The metadata attribute name to provide the thumbnail width.
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 6
Plugin::getClass public function Gets the class of the annotated class. Overrides AnnotationInterface::getClass 1
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 1
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. 3