def thumbnails(html):
    """
    Given a HTML string, converts paths in img tags to thumbnail
    paths, using Mezzanine's ``thumbnail`` template tag. Used as
    one of the default values in the ``RICHTEXT_FILTERS`` setting.
    """
    from django.conf import settings
    from bs4 import BeautifulSoup
    from mezzanine.core.templatetags.mezzanine_tags import thumbnail
    if settings.MEDIA_URL.lower() not in html.lower():
        return html
    dom = BeautifulSoup(html, 'html.parser')
    for img in dom.findAll('img'):
        src = img.get('src', '')
        src_in_media = src.lower().startswith(settings.MEDIA_URL.lower())
        width = img.get('width')
        height = img.get('height')
        if src_in_media and width and height:
            img['src'] = settings.MEDIA_URL + thumbnail(src, width, height)
    return str(dom)
