@register.filter<EOL>def resolution(file_, resolution_string):
if sorl_settings.THUMBNAIL_DUMMY:<EOL><INDENT>dummy_source = sorl_settings.THUMBNAIL_DUMMY_SOURCE<EOL>source = dummy_source.replace('<STR_LIT>', '<STR_LIT>')<EOL>source = source.replace('<STR_LIT>', '<STR_LIT>')<EOL>source = re.compile(source)<EOL>try:<EOL><INDENT>resolution = decimal.Decimal(resolution_string.strip('<STR_LIT:x>'))<EOL>info = source.match(file_).groupdict()<EOL>info = {dimension: int(int(size) * resolution) for (dimension, size) in info.items()}<EOL>return dummy_source % info<EOL><DEDENT>except (AttributeError, TypeError, KeyError):<EOL><INDENT>return file_<EOL><DEDENT><DEDENT>filename, extension = os.path.splitext(file_)<EOL>return '<STR_LIT>' % (filename, resolution_string, extension)<EOL>
A filter to return the URL for the provided resolution of the thumbnail.