skyonline

图片支持问题

  •  
  •   skyonline · Sep 20, 2010 · 5314 views
    This topic created in 5721 days ago, the information mentioned may be changed or developed.
    如果是所有的图片都能支持的话,下面这段代码该怎样修改呢?
    # auto convert img.ly/abcd links to image tags
    def imgly(value):
    imgs = re.findall('(http://img.ly/[a-zA-Z0-9]+)\s?', value)
    if (len(imgs) > 0):
    for img in imgs:
    img_id = re.findall('http://img.ly/([a-zA-Z0-9]+)', img)
    if (img_id[0] != 'system' and img_id[0] != 'api'):
    value = value.replace('http://img.ly/' + img_id[0], '<a href="http://img.ly/' + img_id[0] + '" target="_blank"><img src="http://zdxproxy.appspot.com/img.ly/show/large/' + img_id[0] + '" class="imgly" border="0" /></a>')
    return value
    else:
    return value
    register.filter(imgly)

    # auto convert cl.ly/abcd links to image tags
    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
    3 replies    1970-01-01 08:00:00 +08:00
    skyonline
        1
    skyonline  
    OP
       Sep 21, 2010
    顶下。
    skyonline
        2
    skyonline  
    OP
       Sep 23, 2010
    再顶下
    jckwei
        3
    jckwei  
       Sep 23, 2010
    路过顶一下

    不能包括所有的图片,比如大多数图片url后缀是jpg,gif,png等,
    有些图片根本没有后缀,修改正则也只能匹配特定的图片网址类型
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3338 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 11:14 · PVG 19:14 · LAX 04:14 · JFK 07:14
    ♥ Do have faith in what you're doing.