1. XenForo 1.5.14 中文版——支持中文搜索!现已发布!查看详情
  2. Xenforo 爱好者讨论群:215909318 XenForo专区

PHP 菜鸟求助 管于 WP 获取文章第一张图片问题

Discussion in '精品源码' started by SHARED, 2015-02-01.

  1. SHARED

    SHARED VIP会员

    Joined:
    2013-05-30
    Messages:
    37
    Likes Received:
    9
    百度了一些文章 都是针对代码是
    Code:
    <img src="http://xxx.jpg">
    这种形式的解决方案

    如果是
    Code:
    [img]http://xxx.jpg[/img]
    该怎样修改下面红色部分呢

    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
     
  2. admin

    admin 管理员 Staff Member

    Joined:
    2011-11-01
    Messages:
    3,671
    Likes Received:
    2,425
    实在不行 试试插件wp-thumbnails
     
  3. SHARED

    SHARED VIP会员

    Joined:
    2013-05-30
    Messages:
    37
    Likes Received:
    9
    多谢石头大大。自己虽是个菜鸟,但还想偷个懒。我再琢磨琢磨咋弄。
     
  4. SHARED

    SHARED VIP会员

    Joined:
    2013-05-30
    Messages:
    37
    Likes Received:
    9
    问题已解决,是php下正则表达式写法的问题
     
  5. mrland456

    mrland456 入门会员

    Joined:
    2016-12-27
    Messages:
    8
    Likes Received:
    0
    谢谢
     
Loading...