Loading core/misc/cspell/dictionary.txt +1 −0 Original line number Diff line number Diff line Loading @@ -366,6 +366,7 @@ pickable pingback placeholdered placeholdering playsinline plusthick porterstemmer postcondition Loading core/modules/file/config/schema/file.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,9 @@ field.formatter.settings.file_video: muted: type: boolean label: 'Muted' playsinline: type: boolean label: 'Plays inline' width: type: integer label: 'Width' Loading core/modules/file/file.module +10 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ use Drupal\Core\Template\Attribute; use Drupal\file\FileInterface; use Drupal\file\IconMimeTypes; use Drupal\file\Plugin\Field\FieldFormatter\FileVideoFormatter; use Drupal\file\Upload\FileUploadHandlerInterface; use Drupal\file\Upload\FormUploadedFile; Loading Loading @@ -765,3 +766,12 @@ function file_system_settings_submit(array &$form, FormStateInterface $form_stat ->set('filename_sanitization', $form_state->getValue('filename_sanitization')); $config->save(); } /** * Implements hook_ENTITY_TYPE_presave(). */ function file_file_video_presave(FileVideoFormatter $formatter): void { if ($formatter->getSetting('playsinline') === NULL) { $formatter->setSetting('playsinline', FALSE); } } core/modules/file/file.post_update.php +24 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ * Post update functions for File. */ use Drupal\Core\Config\Entity\ConfigEntityUpdater; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Implements hook_removed_post_updates(). */ Loading @@ -15,3 +19,23 @@ function file_removed_post_updates(): array { 'file_post_update_add_default_filename_sanitization_configuration' => '11.0.0', ]; } /** * Adds a value for the 'playsinline' setting of the 'file_video' formatter. */ function file_post_update_add_playsinline(array &$sandbox = []): ?TranslatableMarkup { /** @var \Drupal\Core\Config\Entity\ConfigEntityUpdater $config_entity_updater */ $config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class); return $config_entity_updater->update($sandbox, 'entity_view_display', function (EntityViewDisplayInterface $display) { $needs_update = FALSE; $components = $display->getComponents(); foreach ($components as $name => $component) { if (isset($component['type']) && $component['type'] === 'file_video') { $needs_update = TRUE; $component['settings']['playsinline'] = FALSE; $display->setComponent($name, $component); } } return $needs_update; }); } core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php +8 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ public static function getMediaType() { public static function defaultSettings() { return [ 'muted' => FALSE, 'playsinline' => FALSE, 'width' => 640, 'height' => 480, ] + parent::defaultSettings(); Loading @@ -47,6 +48,11 @@ public function settingsForm(array $form, FormStateInterface $form_state) { '#type' => 'checkbox', '#default_value' => $this->getSetting('muted'), ], 'playsinline' => [ '#title' => $this->t('Plays Inline'), '#type' => 'checkbox', '#default_value' => $this->getSetting('playsinline'), ], 'width' => [ '#type' => 'number', '#title' => $this->t('Width'), Loading Loading @@ -76,6 +82,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { public function settingsSummary() { $summary = parent::settingsSummary(); $summary[] = $this->t('Muted: %muted', ['%muted' => $this->getSetting('muted') ? $this->t('yes') : $this->t('no')]); $summary[] = $this->t('Plays Inline: %playsinline', ['%playsinline' => $this->getSetting('playsinline') ? $this->t('yes') : $this->t('no')]); if ($width = $this->getSetting('width')) { $summary[] = $this->t('Width: %width pixels', [ Loading @@ -96,7 +103,7 @@ public function settingsSummary() { * {@inheritdoc} */ protected function prepareAttributes(array $additional_attributes = []) { $attributes = parent::prepareAttributes(['muted']); $attributes = parent::prepareAttributes(['muted', 'playsinline']); if (($width = $this->getSetting('width'))) { $attributes->setAttribute('width', $width); } Loading Loading
core/misc/cspell/dictionary.txt +1 −0 Original line number Diff line number Diff line Loading @@ -366,6 +366,7 @@ pickable pingback placeholdered placeholdering playsinline plusthick porterstemmer postcondition Loading
core/modules/file/config/schema/file.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,9 @@ field.formatter.settings.file_video: muted: type: boolean label: 'Muted' playsinline: type: boolean label: 'Plays inline' width: type: integer label: 'Width' Loading
core/modules/file/file.module +10 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ use Drupal\Core\Template\Attribute; use Drupal\file\FileInterface; use Drupal\file\IconMimeTypes; use Drupal\file\Plugin\Field\FieldFormatter\FileVideoFormatter; use Drupal\file\Upload\FileUploadHandlerInterface; use Drupal\file\Upload\FormUploadedFile; Loading Loading @@ -765,3 +766,12 @@ function file_system_settings_submit(array &$form, FormStateInterface $form_stat ->set('filename_sanitization', $form_state->getValue('filename_sanitization')); $config->save(); } /** * Implements hook_ENTITY_TYPE_presave(). */ function file_file_video_presave(FileVideoFormatter $formatter): void { if ($formatter->getSetting('playsinline') === NULL) { $formatter->setSetting('playsinline', FALSE); } }
core/modules/file/file.post_update.php +24 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ * Post update functions for File. */ use Drupal\Core\Config\Entity\ConfigEntityUpdater; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Implements hook_removed_post_updates(). */ Loading @@ -15,3 +19,23 @@ function file_removed_post_updates(): array { 'file_post_update_add_default_filename_sanitization_configuration' => '11.0.0', ]; } /** * Adds a value for the 'playsinline' setting of the 'file_video' formatter. */ function file_post_update_add_playsinline(array &$sandbox = []): ?TranslatableMarkup { /** @var \Drupal\Core\Config\Entity\ConfigEntityUpdater $config_entity_updater */ $config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class); return $config_entity_updater->update($sandbox, 'entity_view_display', function (EntityViewDisplayInterface $display) { $needs_update = FALSE; $components = $display->getComponents(); foreach ($components as $name => $component) { if (isset($component['type']) && $component['type'] === 'file_video') { $needs_update = TRUE; $component['settings']['playsinline'] = FALSE; $display->setComponent($name, $component); } } return $needs_update; }); }
core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php +8 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ public static function getMediaType() { public static function defaultSettings() { return [ 'muted' => FALSE, 'playsinline' => FALSE, 'width' => 640, 'height' => 480, ] + parent::defaultSettings(); Loading @@ -47,6 +48,11 @@ public function settingsForm(array $form, FormStateInterface $form_state) { '#type' => 'checkbox', '#default_value' => $this->getSetting('muted'), ], 'playsinline' => [ '#title' => $this->t('Plays Inline'), '#type' => 'checkbox', '#default_value' => $this->getSetting('playsinline'), ], 'width' => [ '#type' => 'number', '#title' => $this->t('Width'), Loading Loading @@ -76,6 +82,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { public function settingsSummary() { $summary = parent::settingsSummary(); $summary[] = $this->t('Muted: %muted', ['%muted' => $this->getSetting('muted') ? $this->t('yes') : $this->t('no')]); $summary[] = $this->t('Plays Inline: %playsinline', ['%playsinline' => $this->getSetting('playsinline') ? $this->t('yes') : $this->t('no')]); if ($width = $this->getSetting('width')) { $summary[] = $this->t('Width: %width pixels', [ Loading @@ -96,7 +103,7 @@ public function settingsSummary() { * {@inheritdoc} */ protected function prepareAttributes(array $additional_attributes = []) { $attributes = parent::prepareAttributes(['muted']); $attributes = parent::prepareAttributes(['muted', 'playsinline']); if (($width = $this->getSetting('width'))) { $attributes->setAttribute('width', $width); } Loading