我正在使用此代码获取帖子中第一个插入图像的url。有没有办法我可以得到那张照片的ID。
global $post, $posts;
$first_img = \'\';
ob_start();
ob_end_clean();
$output = preg_match_all(\'/<img.+src=[\\\'"]([^\\\'"]+)[\\\'"].*>/i\', $post->post_content, $matches);
$first_image = $matches [1] [0];