diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index 7f02517..5bece4c 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -284,10 +284,9 @@ public function buildForm(array $form, FormStateInterface $form_state, $theme = $local_file = \Drupal::theme()->getActiveTheme()->getPath() . '/' . $default; } - $element['#description'] = t('Examples: @implicit-public-file (for a file in the public filesystem), @explicit-file, or @local-file.', array( - '@implicit-public-file' => isset($friendly_path) ? $friendly_path : $default, - '@explicit-file' => file_uri_scheme($original_path) !== FALSE ? $original_path : 'public://' . $default, + $element['#description'] = t('Enter a path to an image. Drupal will look for the file relative to the Drupal root or the public file system. Explicitly using public:// before the path will only look in the public file system. Examples: @local-file or @explicit-file', array( '@local-file' => $local_file, + '@explicit-file' => file_uri_scheme($original_path) !== FALSE ? $original_path : 'public://' . $default, )); } } @@ -358,7 +357,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) { if ($this->moduleHandler->moduleExists('file')) { // Handle file uploads. - $validators = array('file_validate_is_image' => array()); + $image_factory = \Drupal::service('image.factory'); + $supported_extensions = $image_factory->getSupportedExtensions(); + $supported_extensions[] = 'svg'; + $validators = ['file_validate_extensions' => [implode(' ', $supported_extensions)]]; // Check for a new uploaded logo. $file = file_save_upload('logo_upload', $validators, FALSE, 0); @@ -374,8 +376,6 @@ public function validateForm(array &$form, FormStateInterface $form_state) { } } - $validators = array('file_validate_extensions' => array('ico png gif jpg jpeg apng svg')); - // Check for a new uploaded favicon. $file = file_save_upload('favicon_upload', $validators, FALSE, 0); if (isset($file)) { diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php index 278353d..ee9d12d 100644 --- a/core/modules/system/src/Tests/System/ThemeTest.php +++ b/core/modules/system/src/Tests/System/ThemeTest.php @@ -103,12 +103,10 @@ function testThemeSettings() { ':description' => 'description', )); // Expected default values (if all else fails). - $implicit_public_file = 'logo.svg'; $explicit_file = 'public://logo.svg'; $local_file = $default_theme_path . '/logo.svg'; // Adjust for fully qualified stream wrapper URI in public filesystem. if (file_uri_scheme($input) == 'public') { - $implicit_public_file = file_uri_target($input); $explicit_file = $input; $local_file = strtr($input, array('public:/' => PublicStream::basePath())); } @@ -118,13 +116,11 @@ function testThemeSettings() { } // Adjust for relative path within public filesystem. elseif ($input == file_uri_target($file->uri)) { - $implicit_public_file = $input; $explicit_file = 'public://' . $input; $local_file = PublicStream::basePath() . '/' . $input; } - $this->assertEqual((string) $elements[0], $implicit_public_file); - $this->assertEqual((string) $elements[1], $explicit_file); - $this->assertEqual((string) $elements[2], $local_file); + $this->assertEqual((string) $elements[1], $local_file); + $this->assertEqual((string) $elements[2], $explicit_file); // Verify the actual 'src' attribute of the logo being output in a site // branding block.