geo-coop/web/themes/custom/geofresco/geofresco.theme

34 lines
1.2 KiB
Text

<?php
/**
* Implements hook_preprocess_HOOK() for page templates.
*
* Provide the elements of the branding block in the page.
*/
function geofresco_preprocess_page(&$variables) {
$block_manager = \Drupal::service('plugin.manager.block');
$branding = $block_manager->createInstance('system_branding_block', [])->build();
$variables['site_logo'] = $branding['site_logo']['#uri'];
$variables['site_slogan'] = $branding['site_slogan'];
$variables['site_name'] = $branding['site_name'];
}
// Below workaround to prevent upscaling of responsive images taken from
// https://drupal.stackexchange.com/questions/254109/how-to-add-a-width-attribute-to-a-responsive-image-with-srcset
// see https://www.drupal.org/project/drupal/issues/2999960
/**
* Implements hook_preprocess_responsive_image_formatter().
*
* In order to do an incredibly ugly hack to prevent responsive images from
* upscaling themselves.
WE DECIDED WE WANT TO ALLOW UPSCALING ON THIS SITE
function geofresco_preprocess_responsive_image_formatter(array &$variables) {
$width = $variables['item']->width;
if ($width > 1199) {
return;
}
$variables['responsive_image']['#attributes']['style'] = 'width: ' . $width . 'px';
}
*/