function MediaSource::__construct

Same name in other branches
  1. 10 core/modules/media/src/Attribute/MediaSource.php \Drupal\media\Attribute\MediaSource::__construct()

Constructs a new MediaSource attribute.

Parameters

string $id: The attribute class ID.

\Drupal\Core\StringTranslation\TranslatableMarkup $label: The human-readable name of the media source.

\Drupal\Core\StringTranslation\TranslatableMarkup|null $description: (optional) A brief description of the media source.

string[] $allowed_field_types: (optional) The field types that can be used as a source field for this media source.

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

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.

string $thumbnail_uri_metadata_attribute: (optional) The metadata attribute name to provide the thumbnail URI.

string $thumbnail_width_metadata_attribute: (optional) The metadata attribute name to provide the thumbnail width.

string $thumbnail_height_metadata_attribute: (optional) The metadata attribute name to provide the thumbnail height.

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.

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.

string $default_name_metadata_attribute: (optional) The metadata attribute name to provide the default name.

class-string|null $deriver: (optional) The deriver class.

Overrides Plugin::__construct

1 method overrides MediaSource::__construct()
OEmbedMediaSource::__construct in core/modules/media/src/Attribute/OEmbedMediaSource.php
Constructs a new OEmbedMediaSource attribute.

File

core/modules/media/src/Attribute/MediaSource.php, line 71

Class

MediaSource
Defines a MediaSource attribute.

Namespace

Drupal\media\Attribute

Code

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) {
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.