wp_get_attachment_image_src(参数1<int>,[选填]参数2<string><int[]>,[选填]参数3<bool>)
描述:获取文章特色图像路径
参数1:
分类的ID或分类对象
$attachment_id:图像的ID
参数2:
获取指定尺寸的图像,可选值:
thumbnail(默认值 – 缩略图大小)medium(中等大小)large(大尺寸)full(原始图片)array(300, 240)(指定宽高)
参数3:
是否使用媒体图标来表示当前图片,布尔类型。
比如:如果当前id是视频的话,此时这里选true,可以直接显示媒体图标。
$icon:false
使用方法
<?php
$image_attributes = wp_get_attachment_image_src(1);
echo $image_attributes[0]; // 图片路径
echo $image_attributes[1]; // 图片宽度
echo $image_attributes[2]; // 图片高度
?>