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

Thumbnail is not working,

Started by Muut Archive 11 years ago · 5 replies · 581 views
11 years ago

Tried to create thumbnails for my gallery, pages/01.gallery, but i coudn't make it work, is there anything wrong with my code ?
{% for portfolio in page.header.images %}
<li>
<a class="thumb" name="leaf" href="{{page.media[portfolio.image].url}}" title="First Photo">
{{ page.media[portfolio.image].thumbnail('default').display('thumbnail').html('Sample Image') }}
</a>
<div class="caption">
<div class="download">
<a href="{{ page.media[portfolio.image].url }}">Download Original</a>
</div>
<div class="image-title">Title #0</div>
<div class="image-desc">Description</div>
</div>
</li>
{% endfor %}

11 years ago

Did you provide a thumbnail file in the format: my_original.jpg.thumb.jpg assuming the regular image is called my_original.jpg ?

Then you would access this via:

TWIG
{{ page.media['my_original.jpg'].thumbnail.html }}
11 years ago

Also you don't actually need to provide a thumbnail, you can create one dynamically with the media functions:

TWIG
{{ page.media['my_original.jpg'].cropResize(100,100).html }}
👍 1
11 years ago

i thought page.media[portfolio.image].thumbnail('default').display('thumbnail').html('Sample Image') }}
is sufficient to make a thumbnail, (didn't find any documentation) and thanks, i followed your second method and it worked.

👍 1
11 years ago

How to make all the cropped images same size, what if some images has different aspect ratio ?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1341 9 years ago
Archive · by Muut Archive, 9 years ago
2 928 9 years ago
Archive · by Muut Archive, 9 years ago
2 4057 9 years ago
Archive · by Muut Archive, 9 years ago
1 2942 9 years ago
Archive · by Muut Archive, 9 years ago
3 1115 9 years ago