在filters.py里
def clly(value):
imgs = re.findall('(http://cl.ly/[a-zA-Z0-9]+)\s?', value)
if (len(imgs) > 0):
for img in imgs:
img_id = re.findall('http://cl.ly/([a-zA-Z0-9]+)', img)
if (img_id[0] != 'demo' and img_id[0] != 'whatever'):
value = value.replace('http://cl.ly/' + img_id[0], '<a href="http://cl.ly/' + img_id[0] + '" target="_blank"><img src="http://cl.ly/' + img_id[0] + '/content" class="imgly" border="0" /></a>')
return value
else:
return value
register.filter(clly)
对图片的解析是替换的,如果同时放两张同样的图片地址,估计会有问题。
用了一张坛子里的图片试一下
" target="_blank">
/content" class="imgly" border="0" />
" target="_blank">
/content" class="imgly" border="0" />
def clly(value):
imgs = re.findall('(http://cl.ly/[a-zA-Z0-9]+)\s?', value)
if (len(imgs) > 0):
for img in imgs:
img_id = re.findall('http://cl.ly/([a-zA-Z0-9]+)', img)
if (img_id[0] != 'demo' and img_id[0] != 'whatever'):
value = value.replace('http://cl.ly/' + img_id[0], '<a href="http://cl.ly/' + img_id[0] + '" target="_blank"><img src="http://cl.ly/' + img_id[0] + '/content" class="imgly" border="0" /></a>')
return value
else:
return value
register.filter(clly)
对图片的解析是替换的,如果同时放两张同样的图片地址,估计会有问题。
用了一张坛子里的图片试一下