@register.filter
def resolution(file_, resolution_string):
 if sorl_settings.THUMBNAIL_DUMMY:
  dummy_source = sorl_settings.THUMBNAIL_DUMMY_SOURCE
  source = dummy_source.replace(u'%(width)s', u'(?P<width>[0-9]+)')
  source = source.replace(u'%(height)s', u'(?P<height>[0-9]+)')
  source = re.compile(source)
  try:
   resolution = decimal.Decimal(resolution_string.strip(u'x'))
   info = source.match(file_).groupdict()
   info = {dimension: int((int(size) * resolution)) for (dimension, size) in info.items()}
   return (dummy_source % info)
  except (AttributeError, TypeError, KeyError):
   return file_
 (filename, extension) = os.path.splitext(file_)
 return (u'%s@%s%s' % (filename, resolution_string, extension))

@ register . filter def resolution ( file_ , resolution_string ) : if sorl_settings . THUMBNAIL_DUMMY : dummy_source = sorl_settings . THUMBNAIL_DUMMY_SOURCE source = dummy_source . replace ( u'%(width)s' , u'(?P<width>[0-9]+)' ) source = source . replace ( u'%(height)s' , u'(?P<height>[0-9]+)' ) source = re . compile ( source ) try : resolution = decimal . Decimal ( resolution_string . strip ( u'x' ) ) info = source . match ( file_ ) . groupdict ( ) info = { dimension : int ( ( int ( size ) * resolution ) ) for ( dimension , size ) in info . items ( ) } return ( dummy_source % info ) except ( AttributeError , TypeError , KeyError ) : return file_ ( filename , extension ) = os . path . splitext ( file_ ) return ( u'%s@%s%s' % ( filename , resolution_string , extension ) )
a filter to return the url for the provided resolution of the thumbnail .