๐Ÿ–ผ๏ธ 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).

โ† Specific Content tags Tags โ†’

This site uses cookies for essential functionality and to improve your experience. See our Privacy Policy.