Skip to content
Snippets Groups Projects
Commit 3fd9514d 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 7cf9fb43 9a0d88d2
No related branches found
No related tags found
No related merge requests found
Pipeline #132548 failed
......@@ -151,12 +151,23 @@ public function build() {
$build = [];
$site_config = $this->configFactory->get('system.site');
$logo_uri = theme_get_setting('logo.url');
$extension = pathinfo($logo_uri, PATHINFO_EXTENSION);
$build['site_logo'] = [
'#theme' => 'image',
'#uri' => theme_get_setting('logo.url'),
'#uri' => $logo_uri,
'#alt' => $this->t('Home'),
'#attributes' => ['loading' => 'eager', 'fetchpriority' => 'high'],
'#access' => $this->configuration['use_site_logo'],
];
$image = \Drupal::service('image.factory')->get($logo_uri);
if ($image->isValid()) {
$build['site_logo']['width'] = $image->getWidth();
$build['site_logo']['height'] = $image->getHeight();
}
else {
dump('boo');
}
$build['site_name'] = [
'#markup' => $site_config->get('name'),
......
......@@ -798,8 +798,13 @@ 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['deprecations'] = [
'site_logo' => "'site_logo' is deprecated in drupal:10.3.0 and is removed from drupal:12.0.0. Use the 'logo' variable which include the rendered img tag instead. See https://www.drupal.org/node/3436978",
];
$variables['site_name'] = '';
if ($variables['content']['site_name']['#access'] && $variables['content']['site_name']['#markup']) {
$variables['site_name'] = $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