class MediaSource
Same name in other branches
- 8.9.x core/modules/media/src/Annotation/MediaSource.php \Drupal\media\Annotation\MediaSource
- 10 core/modules/media/src/Annotation/MediaSource.php \Drupal\media\Annotation\MediaSource
- 11.x core/modules/media/src/Annotation/MediaSource.php \Drupal\media\Annotation\MediaSource
- 10 core/modules/media/src/Attribute/MediaSource.php \Drupal\media\Attribute\MediaSource
- 11.x core/modules/media/src/Attribute/MediaSource.php \Drupal\media\Attribute\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
- class \Drupal\Component\Annotation\Plugin implements \Drupal\Component\Annotation\AnnotationInterface
- class \Drupal\media\Annotation\MediaSource extends \Drupal\Component\Annotation\Plugin
Expanded class hierarchy of MediaSource
See also
\Drupal\media\MediaSourceInterface
\Drupal\media\MediaSourceManager
hook_media_source_info_alter()
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.
File
-
core/
modules/ media/ src/ Annotation/ MediaSource.php, line 26
Namespace
Drupal\media\AnnotationView 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
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | 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 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.