Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

TWIG: Crop Image of Collection

Started by Muut Archive 10 years ago · 3 replies · 773 views
10 years ago

I have a page collection that provides an image in the collection header (has been uploaded through the admin panel directly to the page). I want to cropResize() this image but I do not get it to work. My code:

TWIG
{% for product in categ.collection %}
{% set prdimage = product.media.images[product.header.image] %}
{{prdimage.cropResize(100,100).html()}}
{% endfor %}

returns nothing. any ideas?

10 years ago

Also, try dumping those variables to the debug bar to check if product is actually something, and same for product.media.images and prdimage

10 years ago

sorry for my late reply. wsanter's answer FTW :)

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1362 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2959 9 years ago
Archive · by Muut Archive, 9 years ago
3 1124 9 years ago