Use up and down keys to navigate results once you've typed more than two characters. Use the enter key to select a result. Touch device users, explore by touch or with swipe gestures.
Information and media Image
Overview
Adds an image to the page with an optional caption.
Improved approach for retina screens
Uses two versions of the image, one for standard screens and the other for retina screens.
We specify a folder path for both small and large images which is defined in the macro as smallSrc and largeSrc. The filename is expected to be the same for both.
If the image is decorative and does not convey important information, do not add an alt tag. This will then be hidden from screen reader users.
{% from "components/image/_macro.njk" import onsImage %}
{{
onsImage({
"src": '/img/small/woman-in-purple-dress-shirt.jpg',
"alt": 'Woman in a purple dress shirt using a laptop',
"caption": 'Image 1 - Woman in a purple dress shirt using a laptop'
})
}}
Nunjucks macro options
[object Object]undefined
[object Object]
[object Object]undefined
HTML
<figure class="ons-figure">
<div class="
ons-figure__content
ons-u-mb-l
">
<div class="ons-image">
<img class="ons-image__img" src="/img/small/woman-in-purple-dress-shirt.jpg"
alt="Woman in a purple dress shirt using a laptop" />
</div>
</div>
<figcaption class="ons-figure__caption">Image 1 - Woman in a purple dress shirt using a laptop</figcaption>
</figure>