Skip to content
Snippets Groups Projects

Improve description about same file extension requirement.

1 file
+ 5
2
Compare changes
  • Side-by-side
  • Inline
@@ -114,9 +114,12 @@ function media_entity_file_replace_form_media_form_alter(&$form, FormStateInterf
];
$form['replace_file']['replacement_file']['#description'] = \Drupal::service('renderer')->renderPlain($helpText);
// Inform the user that when replacing the original file, the new one
// must have the same extension.
$originalExtension = '.' . pathinfo($fileFieldItem->entity->getFilename(), PATHINFO_EXTENSION);
$form['replace_file']['keep_original_filename'] = [
'#title' => t('Overwrite original file'),
'#description' => t('When checked, the original filename is kept and its contents are replaced with the new file. If unchecked, the filename of the replacement file will be used, and the original file may be deleted if no previous revision references it (depending on your specific site configuration).'),
'#title' => t('Overwrite original file (@originalExtension)', ['@originalExtension' => $originalExtension]),
'#description' => t('When checked, the original filename is kept and its contents are replaced with the new file, which <strong>must have the same file extension: @originalExtension</strong>. If unchecked, the filename of the replacement file will be used with any allowed file type and the original file may be deleted if no previous revision references it (depending on your specific site configuration).', ['@originalExtension' => $originalExtension]),
'#type' => 'checkbox',
'#default_value' => TRUE,
];
Loading