def content_fit(comment_or_content, fit_w, fit_h, *image_types, **kwargs):
    """
    Renders an html snippet (includes an img tag) for `content_details`.

    `image_types`:
        Could be "column", "stream" for example. Image types are tried in order,
        and the first one that exists for an image is used.
    """
    lazy = kwargs.pop('lazy', False)

    if hasattr(comment_or_content, 'reply_content'):
        details = comment_or_content.reply_content
        visibility = comment_or_content.visibility
    else:
        details = comment_or_content
        visibility = True
    if not isinstance(details, ContentDetails):
        details = ContentDetails(details)

    for image_type in image_types:
        try:
            data = details[image_type]
            url = details.get_absolute_url_for_image_type(image_type)
            wh = _size_attrs(data, fit_w, fit_h)
        except (AttributeError, KeyError, IndexError,):
            # For now, we just show blank images when the content is missing, until we fix the thumbnailer.
            url = str(type)
            wh = {'width': 100, 'height': 100}
        else:
            break
    attribs = {
        'url': url,
        'width': wh['width'],
        'height': wh['height'],
        # @TODO: Note the @comment here is a dict. The current version of the details does not store
        # is_visbile. Hence, we're duplicating the is_visibile code here.
        #TODO just wrap with CommentDetails and call is_visible on it.
        'alt': '',
        'classes': '',
        'extra': '',
    }

    if lazy:
        attribs.update({
            'url': '/static/img/0.gif',
            'extra': 'data-original="{}"'.format(url),
            'classes': 'lazy',
        })

    tag = u'<img class="ugc_img {classes}" src="{url}" width="{width}" height="{height}" alt="{alt}" {extra}>'.format(**attribs)
    return Markup(tag)
def content(comment, content_details, image_type):
    """ Renders an html snippet (includes an img tag) for @content_details.
        param @image_type: Could be "column" 
    """
    details = content_details
    if not isinstance(details, ContentDetails):
        details = ContentDetails(details)

    data = details[image_type]
    wh = _size_attrs(data)

    return {
        'url': details.get_absolute_url_for_image_type(image_type),
        'width': wh['width'],
        'height': wh['height'],
        # @TODO: Note the @comment here is a dict. The current version of the details does not store
        # is_visbile. Hence, we're duplicating the is_visibile code here.
        'alt': '',
    }