Created
March 9, 2012 03:38
-
-
Save Quasimo/2004885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# auto convert imgur.com links to image tags | |
def imgur(value): | |
imgs = re.findall('(http://imgur.com/[a-zA-Z0-9\/]+)\s?', value) | |
if (len(imgs) > 0): | |
for img in imgs: | |
img_id = re.findall('http://imgur.com/([a-zA-Z0-9\/]+)', img) | |
if (img_id[0] != ''): | |
value = value.replace('http://imgur.com/' + img_id[0], '<a href="http://imgur.com/' + img_id[0] + '" target="_blank"><img src="http://i.imgur.com/' + img_id[0] + '.jpg" class="imgly" border="0" /></a>') | |
return value | |
else: | |
return value | |
register.filter(imgur) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment