Ling.ma

请教大胡子wpjam_get_post_first_image

Ling.ma - 8 年 前前

function wpjam_get_post_first_image($post_content=\'\', $size=\'full\'){
if(!$post_content){
$the_post = get_post();
$post_content = $the_post->post_content;
}

preg_match_all( \'/class=[\\\'\"].*?wp-image-([d]*)[\\\'\"]/i\', $post_content, $matches );
if( $matches && isset($matches[1]) && isset($matches[1][0]) ){
$image_id = $matches[1][0];
if($image_url = wpjam_get_post_image_url($image_id, $size)){
return $image_url;
}
}

preg_match_all(\'|

3条回复

- 8 年前

不知道你想说什么

Ling.ma
Ling.ma - 8 年前

汗。。有字数限制。。这个是输出获取日志中的第一个图片地址,如果要输出文章中的所有图片呢。
$matches 数组这里怎么遍历输出

Denis | 邓鸿华
Denis | 邓鸿华 - 8 年前

基础 php 问题,自己搜索

我要回复

暂时不支持网页回复,请安装 WPJAM-Basic 插件,然后在 WordPress 后台即可参与讨论。