def text_filter(regex_base, value):
regex = regex_base % {<EOL>'<STR_LIT>': r'<STR_LIT>',<EOL>'<STR_LIT>': r'<STR_LIT>'<EOL>}<EOL>images = re.findall(regex, value)<EOL>for i in images:<EOL><INDENT>image = i[<NUM_LIT:1>]<EOL>if image.startswith(settings.MEDIA_URL):<EOL><INDENT>image = image[len(settings.MEDIA_URL):]<EOL><DEDENT>im = get_thumbnail(image, str(sorl_settings.THUMBNAIL_FILTER_WIDTH))<EOL>value = value.replace(i[<NUM_LIT:1>], im.url)<EOL><DEDENT>return value<EOL>
Helper method to regex replace images with captions in different markups