def caption(picture):
    """
    Filter to format the caption for a picture.
    
    Usage: {{ picture|caption }}
    
    If an object without a name or desciption is used, an empty string is returned.
    """
    if hasattr(picture, 'name') and hasattr(picture, 'description'):
        return '<a href="%s">%s</a><p>%s</p>' % \
            (picture.get_absolute_url(), picture.name, picture.description or '')
    else:
        return ''