该问题已被锁定!
6
关注
4060
浏览

怎么调用问题或文章附件里的图片,来做封面

AI智能回复搜索中,请稍后...

为什么被折叠? 0 个回复被折叠
sl514 中级会员 用户来自于: 江苏省苏州市
2015-03-13 12:54
function catch_that_image($message) { //$message为文章内容
  $first_img = '';
  ob_start();
  ob_end_clean();
  $output = preg_match_all('/[\'"]([^\'"]+)[\'"].*>/i', $message, $matches);  //正则匹配文章中所有图片
  $first_img = $matches [1] [0];

  if(empty($first_img)){ //定义默认图片
    $first_img = "/images/default.jpg";  //默认图片地址需自己设置
  }
  return $first_img;
}

关于作者

问题动态

发布时间
2015-03-13 11:08
更新时间
2015-03-13 12:54
关注人数
6 人关注

推荐内容

wecenter版本更新 怎么更新我的wecenter阿
手机端启用独立m.baidu.com域名
{新年快乐}WeCenter 2.5 Beta 5 发布
wecenter 和 cpf 哪个好用
wecenter手机端和小程序界面截图,可以继续改进
ajax弹出登陆框的实现
举报理由是摆设啊?