Skip to content
Snippets Groups Projects
Commit a6c277f6 authored by catch's avatar catch
Browse files

Merge branch '3345259-logo-image-dimensions' into '11.x'

Beginnings of rendering image normally in the branding block.

See merge request !7241
parents 1f1d1ab3 733df667
No related branches found
No related tags found
No related merge requests found
Pipeline #132495 failed
Pipeline: drupal

#132500

    ......@@ -151,10 +151,26 @@ public function build() {
    $build = [];
    $site_config = $this->configFactory->get('system.site');
    $logo_uri = theme_get_setting('logo.url');
    $extension = pathinfo($logo_uri, PATHINFO_EXTENSION);
    // getimagesize() doesn't support svg, load the XML instead.
    if ($extension === 'svg') {
    $svg = simplexml_load_file(\Drupal::root() . $logo_uri);
    $attributes = $svg->attributes();
    $width = strval($attributes->width);
    $height = strval($attributes->height);
    }
    else {
    [$width, $height] = getimagesize(\Drupal::root() . $logo_uri);
    }
    $build['site_logo'] = [
    '#theme' => 'image',
    '#uri' => theme_get_setting('logo.url'),
    '#uri' => $logo_uri,
    '#alt' => $this->t('Home'),
    '#width' => $width,
    '#height' => $height,
    '#attributes' => ['loading' => 'eager', 'fetchpriority' => 'high'],
    '#access' => $this->configuration['use_site_logo'],
    ];
    ......
    ......@@ -798,7 +798,9 @@ function system_preprocess_block(&$variables) {
    case 'system_branding_block':
    $variables['site_logo'] = '';
    if ($variables['content']['site_logo']['#access'] && $variables['content']['site_logo']['#uri']) {
    // @todo: deprecate the site_logo variable.
    $variables['site_logo'] = $variables['content']['site_logo']['#uri'];
    $variables['logo'] = $variables['content']['site_logo'];
    }
    $variables['site_name'] = '';
    if ($variables['content']['site_name']['#access'] && $variables['content']['site_name']['#markup']) {
    ......
    ......@@ -8,7 +8,8 @@
    * enabled in the block configuration.
    *
    * Available variables:
    * - site_logo: Logo for site as defined in Appearance or theme settings.
    * - logo: Logo for site as defined in Appearance or theme settings.
    * - site_logo: (deprecated) Logo URI for site as defined in Appearance or theme settings.
    * - site_name: Name for site as defined in Site information settings.
    * - site_slogan: Slogan for site as defined in Site information settings.
    *
    ......@@ -16,9 +17,9 @@
    */
    #}
    {% block content %}
    {% if site_logo %}
    {% if logo %}
    <a href="{{ path('<front>') }}" rel="home">
    <img src="{{ site_logo }}" alt="{{ 'Home'|t }}" fetchpriority="high" />
    {{ logo }}
    </a>
    {% endif %}
    {% if site_name %}
    ......
    ......@@ -8,7 +8,8 @@
    * enabled in the block configuration.
    *
    * Available variables:
    * - site_logo: Logo for site as defined in Appearance or theme settings.
    * - logo: logo for site as defined in appearance or theme settings.
    * - site_logo: (deprecated) logo URI for site as defined in appearance or theme settings.
    * - site_name: Name for site as defined in Site information settings.
    * - site_slogan: Slogan for site as defined in Site information settings.
    */
    ......@@ -16,9 +17,9 @@
    {% set attributes = attributes.addClass('site-branding') %}
    {% block content %}
    <div class="site-branding__inner">
    {% if site_logo %}
    {% if logo %}
    <a href="{{ path('<front>') }}" rel="home" class="site-branding__logo">
    <img src="{{ site_logo }}" alt="{{ 'Home'|t }}" fetchpriority="high" />
    {{ logo }}
    </a>
    {% endif %}
    {% if site_name %}
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment