I'm new to Bolt and I'm trying to get the original width of an image in a record's imagelist. The variables for 'image' only include filename, title, id, order and file, so image.width|image doesn't do anything. I'd rather not use the thumbnail(width, height) method, unless I can access the image's full size dimensions with it, not a cropped version.
https://docs.bolt.cm/record-and-records#imagelist
https://docs.bolt.cm/templatetags#imageinfo
Is there a way to use imageinfo() within the imagelist loop to get the width and height, or is there a better way to go about it? Thanks for your help!
{% setcontent myprojects = 'projects' %}
{% for project in myprojects %}
<div class="slide">
{% for image in project.imagelist %}
<img src="{{ image.filename|image }}" width="{{ image.width|image }}" height="{{ image.height|image }}">
{% endfor %}
</div>
{% endfor %}
Just had the same problem myself and have been on irc discussing this with the bolt team. As the imagelist returns an array, not just a filename, you need to using the filename property as the parameter to imageinfo.
I am doing the following in my template, a similar approach should solve your problem:
{% for galleryImage in record.gallery %}
<li>
<a href="{{ imageinfo(galleryImage.filename).url }}" title="{{ galleryImage.title }}">
{% if imageinfo(galleryImage.filename).landscape %}
<img src="{{ thumbnail(galleryImage, 0, 240) }}" class="landscape">
{% elseif imageinfo(galleryImage.filename).portrait %}
<img src="{{ thumbnail(galleryImage, 0, 240) }}" class="portrait">
{% else %}
<img src="{{ thumbnail(galleryImage, 240, 240) }}" class="square">
{% endif %}
</a>
</li>
{% endfor %}