loop through image problem
-
Chet –
I’m having trouble getting [apr_loop] to step through a record’s image field correctly. It seems to work OK when the record is being accessed through a loop of matching records, but not when an individual record is returned.
The first case, the one that works properly, is the one whose solution you provided a few tickets ago. With a virtual post matching on “FIND(‘$1’,genre) > 0” the following code returns a list of matching records. If the ‘images’ field isn’t empty, the line includes a thumbnail for each image. (Indented for readability.)
[apr_loop] {{available}} [apr_loop1 field="images"] <img src="{{thumbnails|small|url}}" /> [/apr_loop1] <a href="/wardrobe/garment/{{slug}}">{{Name}}</a><br /> [/apr_loop]
Clicking on the linked garment Name triggers a second Virtual Post, this time matching “slug = ‘$1’.” (‘Slug’ is a sanitized, lowercase version of the primary ‘Name’ field, concatenated with the record’s Auto Number.)
The post maps to a per-garment template. Unfortunately, the following code on that template returns only the thumbnail of the first attached image:
[apr_loop field="images"]<img src="{{thumbnails|small|url}}">[/apr_loop]
Elsewhere on that page, I loop through a one-to-many linked record without any problem by populating the field and then looping through the related record, so the looping mechanism works.
Caveat: I’m not doing this on a clean install, so there are potential conflicts with the theme and other plugins. I’m hoping that the image loop’s working fine in the first situation means that’s not the case, but I’ll test on a clean install if necessary.
Thanks!
- The topic ‘loop through image problem’ is closed to new replies.