<div class="image-lead">
<div class="image-lead__intro-container">
<div class="image-lead__intro wt-grid-main wt-grid-main-top">
<h1 class="image-lead__intro-text image-lead__intro-text--broguesMid">
<span class="image-lead__intro-inner">Good health makes life better. We want to improve health for everyone by helping great ideas to thrive.</span>
</h1>
</div>
</div>
<div class="image-lead__caption-container">
<div class="image-lead__caption wt-grid-main wt-grid-main-top wt-grid-content-main">
<p class="image-lead__caption-text">
Dolor anim dolore reprehenderit est enim est sunt ut sint non qui adipisicing laboris incididunt ut commodo consectetur cupidatat. <span class="image-lead__caption-text__credit"></span>
</p>
<a class="button scroll-link scroll-link--hidden" href="#main" aria-hidden="true" role="presentation" tabindex="-1"></a>
</div>
</div>
<div class="image-lead__image-container">
<picture>
<!--[if IE 9]><video><![endif]-->
<source type="image/jpeg" media="(orientation: portrait)" srcset="../../assets/images/sample/home-col-test-2-aspect-1.jpg" data-loaded-url="../../assets/images/sample/home-col-test-2-aspect-1.jpg">
<source type="image/jpeg" media="(min-aspect-ratio: 16/9)" srcset="../../assets/images/sample/home-col-test-2-aspect-16to9.jpg" data-loaded-url="../../assets/images/sample/home-col-test-2-aspect-16to9.jpg">
<source type="image/jpeg" media="(orientation: landscape)" srcset="../../assets/images/sample/home-col-test-2-aspect-3to2.jpg" data-loaded-url="../../assets/images/sample/home-col-test-2-aspect-3to2.jpg">
<!--[if IE 9]></video><![endif]-->
<img alt="
Notice: Undefined index: alt_text in /home/ubuntu/corporate/www/sites/all/themes/corp_base/node_modules/tpl-php/transformer.php(20) : eval()'d code on line 29
Call Stack:
0.0002 279320 1. {main}() /home/ubuntu/corporate/www/sites/all/themes/corp_base/node_modules/tpl-php/transformer.php:0
0.0006 294352 2. eval('?><div class=" image-lead ">
<div class="image-lead__intro-container ">
<div class="image-lead__intro wt-grid-main wt-grid-main-top ">
<h1 class="image-lead__intro-text image-lead__intro-text--<?php print $variables[ 'caption_title_background'] ?>">
<span class="image-lead__intro-inner"><?php print $variables['caption_title'] ?></span>
</h1>
</div>
</div>
<div class="image-lead__caption-container">
<div class="image-lead__caption wt-grid-main wt-grid-main-top wt-grid-content-main">
<p class="image-lead__caption-text">
<?php print $variables['caption_text']?>
<span class="image-lead__caption-text__credit"></span>
</p>
<a class="button scroll-link scroll-link--hidden" href="#main" aria-hidden="true" role="presentation" tabindex="-1"></a>
</div>
</div>
<div class="image-lead__image-container">
<picture>
<!--[if IE 9]><video><![endif]-->
<?php foreach ($variables['image_data'] as $image): ?>
<source type="<?php print $image['type']; ?>" media="<?php print $image['media_string']; ?>" srcset="<?php print $image['preload_url']; ?>" data-loaded-url="<?php print $image['loaded_url'] ?>">
<?php endforeach; ?>
<!--[if IE 9]></video><![endif]-->
<img alt="<?php print $variables['alt_text'] ?>" srcset="<?php print $variables['default_img'] ?>">
</picture>
</div>
</div>
<!--<div class="pride-strip"></div>-->
') /home/ubuntu/corporate/www/sites/all/themes/corp_base/node_modules/tpl-php/transformer.php:20 " srcset="../../assets/images/sample/home-col-test-2-aspect-1.jpg">
</picture>
</div>
</div>
<!--<div class="pride-strip"></div>-->
//TODO gather these into settings and make sure shared everywhere they need to be
// need to make work with logowidth settings in mixins.scss
$startTextOverlay: 20em;
$startCollapsedCaption: $startTextOverlay;
$introMediumHeightBreakpoint: 800px;
$introSmallHeightBreakpoint: 700px;
$introTinyHeightBreakpoint: 650px;
.image-lead {
@include respond-to($grid-breakpoint-s) {
min-height: 500px;
// on the homepage, the main is under the image lead, so it needs some spacing
.enhanced & + .wt-grid-main,
.enhanced & + .scroll-link + .wt-grid-main {
// there may be a scroll link between the lead and the main
margin-top: $grid-typo-spacing-m;
}
}
background: $black;
border-bottom: solid $grid-typo-spacing-xxs $ncLighterBlue;
overflow: hidden;
position: relative;
img {
height: auto;
width: 100%;
}
}
.image-lead__intro-container {
box-sizing: border-box;
.enhanced & {
@include rem(padding-left, $grid-typo-spacing-xs);
@include rem(padding-right, $grid-typo-spacing-xs);
@include respond-to($grid-breakpoint-s) {
left: 0;
top: $grid-typo-spacing-xxl + $grid-typo-spacing-xl;
}
@include respond-to($grid-breakpoint-m) {
top: $grid-typo-spacing-xxl + $grid-typo-spacing-xl + $grid-typo-spacing-l;
}
@media all and (max-height: $introMediumHeightBreakpoint) and (min-width: $grid-breakpoint-s) {
top: $grid-typo-spacing-xxl + $grid-typo-spacing-xl;
}
@media all and (max-height: $introSmallHeightBreakpoint) and (min-width: $grid-breakpoint-s) {
top: $headerHeightSticky + $secondaryNavHeight + $grid-typo-spacing-l;
}
@media all and (max-height: $introTinyHeightBreakpoint) and (min-width: $grid-breakpoint-s) {
.image-lead__intro-text {
@include rem(padding, 18px 18px 18px 18px);
font-family: $supplementaryFont;
font-size: $leadIntroFontSizeSmall;
line-height: $leadIntroLineHeightSmall;
width: 2 * $column + 2 * $column-padding;
}
}
@media print {
position: static;
}
bottom: 0;
position: absolute;
width: 100%;
}
}
.image-lead__intro {
height: 100%;
z-index: 2;
}
.image-lead__intro-text {
@include rem(padding, 18px);
@include font-size-with-line-height(
$leadIntroFontSizeSmall,
$leadIntroLineHeightSmall
);
@include respond-to($grid-breakpoint-s) {
font-size: $leadIntroFontSize;
line-height: $leadIntroLineHeight;
}
background: $leadIntroBackgroundColour;
border-top: 0;
color: $white;
font-family: $supplementaryFont;
.enhanced & {
@include respond-to($grid-breakpoint-s) {
margin: 0;
min-height: auto;
width: 4 * $column;
}
@media print {
width: auto;
}
width: auto;
}
}
// here we create a class for each of the brand colours so that DCPs can choose the background colour of the itro in Drupal
@each $name, $colour in $brandColours {
@include classWithColourModifierForProperty(
'image-lead__intro-text',
$name,
$colour,
background
);
}
.image-lead__caption-container {
.enhanced & {
@include respond-to($startCollapsedCaption) {
bottom: 0;
left: 0;
position: absolute;
width: 100%;
}
color: $white;
a {
color: $white;
&:hover {
color: $ncOrange;
}
}
&:before {
@include gradientBackgroundWithOffset(0);
@include rem(padding-bottom, $grid-typo-spacing-xl);
@media print {
content: none;
}
bottom: 0;
content: '';
height: $headerHeightNormal;
position: absolute;
width: 100%;
}
}
}
.enhanced {
.image-lead__caption-text {
@include font-size-with-line-height(
$smallTextFontSize,
$grid-spacing-unit * 3
);
@include rem(padding-top, $grid-spacing-unit);
box-sizing: border-box;
margin-bottom: $grid-typo-spacing-m;
max-width: 8 * $column;
position: relative;
// hide the text but lay it out anyway as that keeps the gradient
visibility: hidden;
z-index: 1;
@include respond-to($grid-breakpoint-s) {
visibility: visible;
}
}
}
.image-lead__image-container,
.image-lead__caption-container {
display: none;
.enhanced & {
display: block;
}
}
.enhanced .image-lead__image-container {
filter: blur(30px) brightness(110%);
opacity: 0.7;
}
.enhanced .image-lead__image-container--loaded {
filter: none;
opacity: 1;
}
.button.scroll-link {
@include largeArrowButton('down');
bottom: 0;
display: none;
opacity: 1;
padding: 0;
position: absolute;
right: 0;
transform: scale(1);
transition: transform $hoverTransLength, opacity $hoverTransLength;
z-index: 100; // to infinity and beyond
@include rem(min-width, $grid-typo-spacing-l); // ovverides button classes
@include respond-to($grid-breakpoint-s) {
display: block;
}
@media print {
display: none;
}
}
.scroll-link--hidden {
opacity: 0;
transform: scale(0);
}
/**
* This method prevents the homepage lead image from getting too tall.
* The design requires the image to be contained within the screen.
* The method also adds a link to scroll the page and act as a
* visual clue to the fact there is content below the image.
* The scroll link fades in and out as needed, depending on the window scroll position.
*/
import Settings from './../../settings';
import { nodeList } from '../../utils/utils.js';
import picturefill from 'picturefill';
export default function imageLead() {
const imageLeadContainer = document.querySelector('.image-lead');
if (!imageLeadContainer) return;
const availableSpace = window.innerHeight - Settings.typoSpacing.xl;
imageLeadContainer.style.overflow = 'hidden';
imageLeadContainer.style.height = 'auto';
// we need to set the height even in case the image headers haven't loaded yet
if (imageLeadContainer.clientHeight > availableSpace || !imageLeadContainer.clientHeight) {
imageLeadContainer.style.overflow = 'hidden';
imageLeadContainer.style.height = `${availableSpace}px`;
}
const imageLeadImageContainer = imageLeadContainer.querySelector('.image-lead__image-container');
const sources = nodeList(imageLeadImageContainer.querySelectorAll('source'));
const imgElement = imageLeadImageContainer.querySelector('img');
// start preloading each of the sources into memory
sources.forEach(s => {
const fullImage = new window.Image();
fullImage.addEventListener('load', e => {
// update the source (need to update both the property and the HTML attribute because of iOS Safari)
s.srcset = s.getAttribute('data-loaded-url');
s.setAttribute('srcset', s.getAttribute('data-loaded-url'));
// Edge won't really have updated the srcset at this point, so we wait a little bit (the exact length of 'little bit' was determined empirically)
setTimeout(() => {
if (!imgElement.currentSrc) {
picturefill({ reevaluate: true, elements: [ imgElement ] });
}
// if this is the currently visible image, unblur
if (imgElement.currentSrc === fullImage.src || !imgElement.currentSrc) {
imageLeadImageContainer.classList.add('image-lead__image-container--loaded');
}
}, 200);
});
fullImage.src = s.getAttribute('data-loaded-url');
});
};
A large responsive image banner with a lead message, caption and an anchor button.
Example usage: https://wellcome.ac.uk
{
"caption_title_background": "broguesMid",
"caption_title": "Good health makes life better. We want to improve health for everyone by helping great ideas to thrive.",
"caption_text": "Dolor anim dolore reprehenderit est enim est sunt ut sint non qui adipisicing laboris incididunt ut commodo consectetur cupidatat.",
"image_data": [
{
"preload_url": "{{ path /assets/images/sample/home-col-test-2-aspect-1.jpg }}",
"loaded_url": "{{ path /assets/images/sample/home-col-test-2-aspect-1.jpg }}",
"media_string": "(orientation: portrait)",
"type": "image/jpeg"
},
{
"preload_url": "{{ path /assets/images/sample/home-col-test-2-aspect-16to9.jpg }}",
"loaded_url": "{{ path /assets/images/sample/home-col-test-2-aspect-16to9.jpg }}",
"media_string": "(min-aspect-ratio: 16/9)",
"type": "image/jpeg"
},
{
"preload_url": "{{ path /assets/images/sample/home-col-test-2-aspect-3to2.jpg }}",
"loaded_url": "{{ path /assets/images/sample/home-col-test-2-aspect-3to2.jpg }}",
"media_string": "(orientation: landscape)",
"type": "image/jpeg"
}
],
"default_img": "{{ path /assets/images/sample/home-col-test-2-aspect-1.jpg }}"
}