๐ผ๏ธ Content Image Loops
Last updated๏ผ2026-11-25
๐ผ๏ธ Iterating Multiple Content Images
The multiple-image fields of articles / products / cases are stored as JSON arrays; parse them with the splitJSON function and iterate.
โก Basic Syntax
<!-- Parse the JSON array into a slice -->
{{range splitJSON .Images}}
<img src="{{.}}" alt="" loading="lazy">
{{end}}
๐ Applicable Fields
- {{.News.Images}} Article multiple-image list โ JSON
- {{.Product.Images}} Product multiple-image list โ JSON
- {{.Case.Images}} Case multiple-image list โ JSON
- {{.News.Attachments}} Article attachment list โ JSON
๐ป Complete Example
<!-- Product detail page carousel (product multiple images) -->
<div class="product-gallery">
{{range splitJSON .Product.Images}}
<img src="{{.}}" alt="" loading="lazy">
{{end}}
</div>
<!-- Article detail page accompanying images (article multiple images) -->
{{range splitJSON .News.Images}}
<figure>
<img src="{{.}}" alt="" loading="lazy">
</figure>
{{end}}
<!-- Article attachment download list -->
{{range splitJSON .News.Attachments}}
<a href="{{.}}" class="attachment" download>Download Attachment</a>
{{end}}
Note: splitJSON is safe for nil / empty strings (returns an empty slice, no error).
CloudSite SaaS