Just a friendly (ho!) update on some of the things I’ve added to my FriendFeed Django application, django-friendly
recently. I needed a way to pull out all the media from an entry. As I mentioned in my original post, getting at that stuff was a nasty mess of object attributes in your templates, so I set out to fix that.
To that end I’ve created a few media-related tags. The first is get_friendfeed_media_list
get_friendfeed_media_list
This is very straightforward as it works just like comments and likes. You might use it in this manner (see second line):
{% get_friendfeed_media_list for [friendfeed_id] as [varname] (limit) %}
...
{% for entry in object_list %}
{% get_friendfeed_media_list for entry.ff_id as media %}
{% if media %}
<dd class="media">
{% for m in media %}
{% ifequal entry.service.ff_id 'youtube' %}
{% oembed 160x120 %}{{ entry.link }}{% endoembed %}
{% else %}
<a href="{{ entry.link }}">
<img src="{{ m.mediathumbnail_set.all.0.url }}"/>
</a>
{% endifequal %}
{% endfor %}
</dd>
{% endif %}
{% endfor %}
...
In some instances you might want to just grab the first thumbnail of the first media object associated with an entry. I use this a lot when displaying Flickr entries in that photo strip at the top of my site. For those instances, I’ve created a tag called get_friendfeed_first_media_thumbnail
. You’d use it in this manner:
{% get_friendfeed_first_media_thumbnail for [friendfeed_id] as [varname] %}
...
{% get_friendfeed_entry_list for 'flickr' 12 as flickr_photos %}
<div class="column span-24 first last" id="photos">
{% for photo in flickr_photos %}
{% get_friendfeed_first_media_thumbnail for photo.ff_id as thumbnail %}
<a href="{{ photo.link }}" rel="photo">
<img src="{{ thumbnail.url }}"
width="{{ thumbnail.width }}"
height="{{ thumbnail.height }}">
</a>
{% endfor %}
</div>
...
I’m thinking about adding some other tags, but so far, I’m not sure. I think I’ll let these percolate for a little while and see if I need any new ones.