Hi all.
I have some extra fields in my page (a modular slideshow) which let the user upload an image, add a title and add a caption. I access these “slides” in my twig template using:
{% for slide in page.header.slider %}
<div class="item{% if loop.first %} first{% endif %}">
{% for image in slide.image %}
<img src="{{ image.path }}" alt="{{ slide.title }}">
{% endfor %}
<div class="carousel-caption">
{{ slide.title }}
{{ slide.text }}
</div>
{% endfor %}
This all works fine
Where I have a problem though is with resizing and cropping the image. Normally you would use something like:
{{ page.media['sample-image.jpg'].resize(400, 200).html() }}
But I can’t use this within the ‘for’ loop. If I put something like:
{{ page.media['image.name'].resize(400, 200).html() }}
I get nothing showing. I have tried with and without the single quotes.
I’m not sure what to do!