Verified Commit 34084569 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2259567 by jcnventura, eelkeblok, joegraduate, thejimbirch, nvahalik,...

Issue #2259567 by jcnventura, eelkeblok, joegraduate, thejimbirch, nvahalik, Lendude, andypost, anmolgoyal74, vacho, oriol_e9g, trackleft2, DamienMcKenna, smustgrave, nelp, LOBsTerr, twills, huzooka, Gauravvvv, xopoc, caesius, gyuhyon, mgifford, joelpittet, fietserwin, mark.labrecque, fabio84, lauriii, greggles, alexpott, mondrake, catch, quietone, drugan, jungle, DuaelFr: Support SVG files for theme logo setting

(cherry picked from commit 537f11dc)
parent a3655355
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -240,7 +240,9 @@ public function buildForm(array $form, FormStateInterface $form_state, $theme =
        '#title' => $this->t('Upload logo image'),
        '#description' => $this->t("If you don't have direct file access to the server, use this field to upload your logo."),
        '#upload_validators' => [
          'FileIsImage' => [],
          'FileExtension' => [
            'extensions' => 'png gif jpg jpeg apng svg',
          ],
        ],
      ];
    }
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ administer site configuration:
  restrict access: true
administer themes:
  title: 'Administer themes'
  restrict access: true
administer software updates:
  title: 'Administer software updates'
  restrict access: true
+25 −12
Original line number Diff line number Diff line
@@ -191,21 +191,34 @@ public function testThemeSettings() {
      $this->assertSession()->pageTextContains('The custom logo path is invalid.');
    }

    // Upload a file to use for the logo.
    // Upload a file to use for the logo. Try both the test image we've been
    // using so far and an SVG file.
    $upload_uris = [$file->uri, 'core/themes/olivero/logo.svg'];
    $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
    foreach ($upload_uris as $upload_uri) {
      $edit = [
        'default_logo' => FALSE,
        'logo_path' => '',
      'files[logo_upload]' => \Drupal::service('file_system')->realpath($file->uri),
        'files[logo_upload]' => \Drupal::service('file_system')->realpath($upload_uri),
      ];
      $this->drupalGet('admin/appearance/settings');
      $this->submitForm($edit, 'Save configuration');
      $this->assertSession()->pageTextContains('The configuration options have been saved.');

      $uploaded_filename = 'public://' . $this->getSession()->getPage()->findField('logo_path')->getValue();

    $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
      $this->drupalGet('');
      $this->assertSession()->elementAttributeContains('xpath', '//header//a[@rel="home"]/img', 'src', $file_url_generator->generateString($uploaded_filename));

      // Clear the logo or it will use previous value.
      $edit = [
        'default_logo' => FALSE,
        'logo_path' => '',
        'files[logo_upload]' => '',
      ];
      $this->drupalGet('admin/appearance/settings');
      $this->submitForm($edit, 'Save configuration');
    }

    $this->container->get('theme_installer')->install(['olivero']);

    // Ensure only valid themes are listed in the local tasks.