1 2 3 4 5 6 7 8 9 10 11 12 13 | def link(url, text='', classes=''):
if not text: text = url
if classes: classes = ' class="%s"' % classes
return """<a href="%s"%s>%s</a>""" % (url, classes, text)
def img(url, alt='', classes=''):
if not url.startswith('http://') and not url[:1]=='/':
#add media_url for relative paths
import settings
url = settings.MEDIA_URL + url
if classes: classes = ' class="%s"' % classes
if alt: alt = ' alt="%s" title="%s"' % (alt, alt)
return """<img src="%s"%s%s>""" % (url, classes, alt)
|
More like this
- iPernity thumbnail helper by sedden 4 years, 6 months ago
- Class Feeds DRY TemplateTag by gmandx 3 years ago
- [UPDATE]Filter to resize a ImageField on demand by rafacdb 4 years, 9 months ago
- EditingMiddleware (quickly open views and templates in your text editor!) by johnboxall 3 years, 11 months ago
- Function to create resized versions of an image from a URL and saving it to a local path by obeattie 6 years, 2 months ago
Comments