AI智能回复搜索中,请稍后...
1 回答
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;
}