class MediaSource
Same name in this branch
- 10 core/modules/media/src/Annotation/MediaSource.php \Drupal\media\Annotation\MediaSource
Same name in other branches
- 9 core/modules/media/src/Annotation/MediaSource.php \Drupal\media\Annotation\MediaSource
- 8.9.x core/modules/media/src/Annotation/MediaSource.php \Drupal\media\Annotation\MediaSource
- 11.x core/modules/media/src/Annotation/MediaSource.php \Drupal\media\Annotation\MediaSource
- 11.x core/modules/media/src/Attribute/MediaSource.php \Drupal\media\Attribute\MediaSource
Defines a MediaSource attribute.
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\Plugin\Attribute\AttributeBase implements \Drupal\Component\Plugin\Attribute\AttributeInterface
- class \Drupal\Component\Plugin\Attribute\Plugin extends \Drupal\Component\Plugin\Attribute\AttributeBase
- class \Drupal\media\Attribute\MediaSource extends \Drupal\Component\Plugin\Attribute\Plugin
- class \Drupal\Component\Plugin\Attribute\Plugin extends \Drupal\Component\Plugin\Attribute\AttributeBase
Expanded class hierarchy of MediaSource
See also
\Drupal\media\MediaSourceInterface
\Drupal\media\MediaSourceManager
hook_media_source_info_alter()
10 files declare their use of MediaSource
- AudioFile.php in core/
modules/ media/ src/ Plugin/ media/ Source/ AudioFile.php - File.php in core/
modules/ media/ src/ Plugin/ media/ Source/ File.php - Image.php in core/
modules/ media/ src/ Plugin/ media/ Source/ Image.php - MediaSourceManager.php in core/
modules/ media/ src/ MediaSourceManager.php - Test.php in core/
modules/ media/ tests/ modules/ media_test_source/ src/ Plugin/ media/ Source/ Test.php
File
-
core/
modules/ media/ src/ Attribute/ MediaSource.php, line 27
Namespace
Drupal\media\AttributeView source
class MediaSource extends Plugin {
/**
* Constructs a new MediaSource attribute.
*
* @param string $id
* The attribute class ID.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
* The human-readable name of the media source.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
* (optional) A brief description of the media source.
* @param string[] $allowed_field_types
* (optional) The field types that can be used as a source field for this
* media source.
* @param class-string[] $forms
* (optional) 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, for example, 'media_library_add'.
* @param string $default_thumbnail_filename
* (optional) 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.
* @param string $thumbnail_uri_metadata_attribute
* (optional) The metadata attribute name to provide the thumbnail URI.
* @param string $thumbnail_width_metadata_attribute
* (optional) The metadata attribute name to provide the thumbnail width.
* @param string $thumbnail_height_metadata_attribute
* (optional) The metadata attribute name to provide the thumbnail height.
* @param string|null $thumbnail_alt_metadata_attribute
* (optional) The metadata attribute name to provide the thumbnail alt.
* "Thumbnail" will be used if the attribute name is not provided.
* @param string|null $thumbnail_title_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.
* @param string $default_name_metadata_attribute
* (optional) The metadata attribute name to provide the default name.
* @param class-string|null $deriver
* (optional) The deriver class.
*/
public function __construct(string $id, TranslatableMarkup $label, ?TranslatableMarkup $description = NULL, array $allowed_field_types = [], array $forms = [], string $default_thumbnail_filename = 'generic.png', string $thumbnail_uri_metadata_attribute = 'thumbnail_uri', string $thumbnail_width_metadata_attribute = 'thumbnail_width', string $thumbnail_height_metadata_attribute = 'thumbnail_height', ?string $thumbnail_alt_metadata_attribute = NULL, ?string $thumbnail_title_metadata_attribute = NULL, string $default_name_metadata_attribute = 'default_name', ?string $deriver = NULL) {
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
AttributeBase::$class | protected | property | The class used for this attribute class. | ||
AttributeBase::$provider | protected | property | The provider of the attribute class. | ||
AttributeBase::get | public | function | Gets the value of an attribute. | Overrides AttributeInterface::get | 6 |
AttributeBase::getClass | public | function | Gets the class of the attribute class. | Overrides AttributeInterface::getClass | 1 |
AttributeBase::getId | public | function | Gets the unique ID for this attribute class. | Overrides AttributeInterface::getId | |
AttributeBase::getProvider | public | function | Gets the name of the provider of the attribute class. | Overrides AttributeInterface::getProvider | |
AttributeBase::setClass | public | function | Sets the class of the attributed class. | Overrides AttributeInterface::setClass | 1 |
AttributeBase::setProvider | public | function | Sets the name of the provider of the attribute class. | Overrides AttributeInterface::setProvider | |
MediaSource::__construct | public | function | Constructs a new MediaSource attribute. | Overrides Plugin::__construct | 1 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.