4

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 %}
lizzmo
  • 203
  • 1
  • 13

2 Answers2

6

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 %}
Tom N Tech
  • 250
  • 1
  • 10
0
{% for image in project.imagelist %}    
{% set exif_data = imageinfo(image).info.exif %}
// extract what data you want from the EXIF object for each image
n1kkou
  • 2,848
  • 2
  • 16
  • 27