Using an image for blog excerpt
I am using an image for the blog excerpt and would like to link the blog post to the image rather than the title of the post which I will not be using on the blog home page.
The post.inc I have now is:
<div class="post">
<h2>{{ post | link_to_item }}</h2>
{{ post.data.excerpt }}
<p class="meta">Posted on {{ post.published_at | date: '%B %d, %Y' }} — <a href="{{ post.path }}#comments">{{ post | comment_count_text }}</a></p>
</div>
Is there a way to link the image, rather than the title to the post?
Thanks!
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Steve Smith on 25 Aug, 2010 02:47 PM
Absolutely, just create the link yourself using the appropriate data. Assume that you have a file upload field in your template data called 'excerpt_image':
<a href="{{ post.path }}"><img src="{{ post.data.excerpt_image.url }}" alt="{{ post.title | h }}" /></a>
3 Posted by Christelle Lachapelle on 27 Aug, 2010 03:59 AM
Thanks Steve!
That did the trick!
Steve Smith closed this discussion on 27 Aug, 2010 01:55 PM.