diff -u b/core/modules/file/config/schema/file.schema.yml b/core/modules/file/config/schema/file.schema.yml --- b/core/modules/file/config/schema/file.schema.yml +++ b/core/modules/file/config/schema/file.schema.yml @@ -70,29 +70,29 @@ type: boolean label: 'Enable Description field' -file.formatter.rich_media: +file.formatter.media: type: mapping - label: 'Rich media display format settings' + label: 'Media display format settings' mapping: controls: type: boolean - label: 'Show controls' + label: 'Show playback controls' autoplay: type: boolean label: 'Autoplay' loop: type: boolean label: 'Loop' - multiple_file_behavior: + multiple_file_display_type: type: string label: 'Display of multiple files' field.formatter.settings.file_audio: - type: file.formatter.rich_media + type: file.formatter.media label: 'Audio file display format settings' field.formatter.settings.file_video: - type: file.formatter.rich_media + type: file.formatter.media label: 'Video file display format settings' mapping: muted: diff -u b/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php --- b/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php +++ b/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php @@ -19,7 +19,7 @@ /** * {@inheritdoc} */ - public static function getMimeType() { + public static function getMediaType() { return 'audio'; } diff -u b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterBase.php b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterBase.php --- b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterBase.php +++ b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterBase.php @@ -22,7 +22,7 @@ 'controls' => TRUE, 'autoplay' => FALSE, 'loop' => FALSE, - 'multiple_file_behavior' => 'tags', + 'multiple_file_display_type' => 'tags', ] + parent::defaultSettings(); } @@ -46,14 +46,14 @@ '#type' => 'checkbox', '#default_value' => $this->getSetting('loop'), ], - 'multiple_file_behavior' => [ + 'multiple_file_display_type' => [ '#title' => $this->t('Display of multiple files'), '#type' => 'radios', '#options' => [ - 'tags' => $this->t('Use multiple @tag tags, each with a single source.', ['@tag' => '<' . static::getMimeType() . '>']), - 'sources' => $this->t('Use multiple sources within a single @tag tag.', ['@tag' => '<' . static::getMimeType() . '>']), + 'tags' => $this->t('Use multiple @tag tags, each with a single source.', ['@tag' => '<' . static::getMediaType() . '>']), + 'sources' => $this->t('Use multiple sources within a single @tag tag.', ['@tag' => '<' . static::getMediaType() . '>']), ], - '#default_value' => $this->getSetting('multiple_file_behavior'), + '#default_value' => $this->getSetting('multiple_file_display_type'), ], ]; } @@ -84,16 +84,16 @@ */ public function settingsSummary() { $summary = []; - $summary[] = $this->t('Controls: %controls', ['%controls' => $this->getSetting('controls') ? $this->t('visible') : $this->t('hidden')]); + $summary[] = $this->t('Playback controls: %controls', ['%controls' => $this->getSetting('controls') ? $this->t('visible') : $this->t('hidden')]); $summary[] = $this->t('Autoplay: %autoplay', ['%autoplay' => $this->getSetting('autoplay') ? $this->t('yes') : $this->t('no')]); $summary[] = $this->t('Loop: %loop', ['%loop' => $this->getSetting('loop') ? $this->t('yes') : $this->t('no')]); - switch ($this->getSetting('multiple_file_behavior')) { + switch ($this->getSetting('multiple_file_display_type')) { case 'tags': - $summary[] = $this->t('Multiple files: Multiple HTML tags'); + $summary[] = $this->t('Multiple file display: Multiple HTML tags'); break; case 'sources': - $summary[] = $this->t('Multiple files: One HTML tag with multiple sources'); + $summary[] = $this->t('Multiple file display: One HTML tag with multiple sources'); break; } return $summary; @@ -113,7 +113,7 @@ $attributes = $this->prepareAttributes(); foreach ($source_files as $delta => $files) { $elements[$delta] = [ - '#theme' => 'file_' . static::getMimeType(), + '#theme' => 'file_' . static::getMediaType(), '#attributes' => $attributes, '#files' => $files, '#cache' => ['tags' => []], @@ -150,7 +150,7 @@ } /** - * Check if given MIME type applies to the one of the formatter. + * Check if given MIME type applies to the media type of the formatter. * * @param string $mime_type * The complete MIME type. @@ -160,7 +160,7 @@ */ protected static function mimeTypeApplies($mime_type) { list($type) = explode('/', $mime_type, 2); - return ($type === static::getMimeType()); + return ($type === static::getMediaType()); } /** @@ -179,8 +179,6 @@ */ protected function getSourceFiles(EntityReferenceFieldItemListInterface $items, $langcode) { $source_files = []; - $multiple_file_behavior = $this->getSetting('multiple_file_behavior'); - // Because we can have the files grouped in a single media tag, we do a // grouping in case the multiple file behavior is not 'tags'. /** @var \Drupal\file\Entity\File $file */ @@ -190,7 +188,7 @@ $source_attributes ->setAttribute('src', file_create_url($file->getFileUri())) ->setAttribute('type', $file->getMimeType()); - if ($multiple_file_behavior === 'tags') { + if ($this->getSetting('multiple_file_display_type') === 'tags') { $source_files[] = [ [ 'file' => $file, diff -u b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterInterface.php b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterInterface.php --- b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterInterface.php +++ b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterInterface.php @@ -6,7 +6,7 @@ * Defines getter methods for FileMediaFormatterBase. * * This interface is used on the FileMediaFormatterBase class to ensure that - * each file media formatter will be based on a MIME type. + * each file media formatter will be based on a media type. * * Abstract classes are not able to implement abstract static methods, * this interface will work around that. @@ -17,10 +17,10 @@ /** - * Gets the applicable MIME type for a formatter. + * Gets the applicable media type for a formatter. * * @return string - * The MIME type of this formatter. + * The media type of this formatter. */ - public static function getMimeType(); + public static function getMediaType(); } diff -u b/core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php --- b/core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php +++ b/core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php @@ -21,7 +21,7 @@ /** * {@inheritdoc} */ - public static function getMimeType() { + public static function getMediaType() { return 'video'; }