Using an image for blog excerpt

Christelle Lachapelle's Avatar

Christelle Lachapelle

25 Aug, 2010 02:39 PM via web

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' }} &mdash; <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!

  1. Support Staff 2 Posted by Steve Smith on 25 Aug, 2010 02:47 PM

    Steve Smith's Avatar

    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>

  2. 3 Posted by Christelle Lachapelle on 27 Aug, 2010 03:59 AM

    Christelle Lachapelle's Avatar

    Thanks Steve!
    That did the trick!

  3. Steve Smith closed this discussion on 27 Aug, 2010 01:55 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

17 May, 2012 10:45 PM
20 Mar, 2012 05:05 PM
26 Apr, 2012 01:40 AM
07 Mar, 2012 04:42 PM