'''
Sorl thumbs for the lazy.
Usage: {% thumb p.image "noimage.png" %}
[Fork it here.](https://gist.github.com/985439)
'''
# tags.py
from django import template
register = template.Library()
@register.inclusion_tag("includes/thumb.html")
def thumb(img_obj, no_image="noimage.png", dim="100x100", no_image_dim="100px", ori="600"):
return { 'img_obj': img_obj,
'no_image':no_image,
'dim': dim,
'no_image_dim':no_image_dim,
'ori':ori, }
# includes/thumb.html
{% load thumbnail %}
{% thumbnail img_obj dim crop="80% top" as im %}
{% thumbnail img_obj ori as ori %}
{% endthumbnail %}
{% empty %}
{% endthumbnail %}