2019-07-28 12:25:34 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_HOOK() for page templates.
|
|
|
|
*
|
|
|
|
* Provide the elements of the branding block in the page.
|
|
|
|
*/
|
2019-07-28 12:33:02 -04:00
|
|
|
function geofresco_preprocess_page(&$variables) {
|
2019-07-28 12:25:34 -04:00
|
|
|
$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.
|
2019-08-08 22:19:21 -04:00
|
|
|
WE DECIDED WE WANT TO ALLOW UPSCALING ON THIS SITE
|
2019-07-28 12:33:02 -04:00
|
|
|
function geofresco_preprocess_responsive_image_formatter(array &$variables) {
|
2019-07-28 12:25:34 -04:00
|
|
|
$width = $variables['item']->width;
|
|
|
|
if ($width > 1199) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$variables['responsive_image']['#attributes']['style'] = 'width: ' . $width . 'px';
|
|
|
|
}
|
2019-08-08 22:19:21 -04:00
|
|
|
*/
|