diff --git a/core/modules/file/config/schema/file.schema.yml b/core/modules/file/config/schema/file.schema.yml index b9f8918f63..5e8d8ce9a0 100644 --- a/core/modules/file/config/schema/file.schema.yml +++ b/core/modules/file/config/schema/file.schema.yml @@ -67,6 +67,49 @@ field.field_settings.file: type: boolean label: 'Enable Description field' +field.formatter.settings.file_audio: + type: mapping + label: 'File audio display format settings' + mapping: + controls: + type: boolean + label: 'Show audio controls' + autoplay: + type: boolean + label: 'Autoplay' + loop: + type: boolean + label: 'Loop' + multiple_file_behavior: + type: string + label: 'Display of multiple files' + +field.formatter.settings.file_video: + type: mapping + label: 'File video display format settings' + mapping: + controls: + type: boolean + label: 'Show audio controls' + autoplay: + type: boolean + label: 'Autoplay' + loop: + type: boolean + label: 'Loop' + muted: + type: boolean + label: 'Muted' + width: + type: integer + label: 'Width' + height: + type: integer + label: 'Height' + multiple_file_behavior: + type: string + label: 'Display of multiple files' + field.formatter.settings.file_default: type: mapping label: 'Generic file format settings' diff --git a/core/modules/file/file.module b/core/modules/file/file.module index a6fc3f6ebe..4161bd8a08 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -571,6 +571,12 @@ function file_theme() { 'file_managed_file' => [ 'render element' => 'element', ], + 'file_audio' => [ + 'variables' => ['files' => [], 'attributes' => NULL], + ], + 'file_video' => [ + 'variables' => ['files' => [], 'attributes' => NULL], + ], // From file.field.inc. 'file_widget_multiple' => [ diff --git a/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php new file mode 100644 index 0000000000..901521e912 --- /dev/null +++ b/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php @@ -0,0 +1,118 @@ + TRUE, + 'autoplay' => FALSE, + 'loop' => FALSE, + 'multiple_file_behavior' => 'tags', + ] + parent::defaultSettings(); + } + + /** + * {@inheritdoc} + */ + public function settingsForm(array $form, FormStateInterface $form_state) { + $element['controls'] = array( + '#title' => $this->t('Show audio controls'), + '#type' => 'checkbox', + '#default_value' => $this->getSetting('controls'), + ); + $element['autoplay'] = array( + '#title' => $this->t('Autoplay'), + '#type' => 'checkbox', + '#default_value' => $this->getSetting('autoplay'), + ); + $element['loop'] = array( + '#title' => $this->t('Loop'), + '#type' => 'checkbox', + '#default_value' => $this->getSetting('loop'), + ); + $element['multiple_file_behavior'] = array( + '#title' => $this->t('Display of multiple files'), + '#type' => 'radios', + '#options' => array( + 'tags' => $this->t('Use multiple @tag tags, each with a single source.', array('@tag' => '