“完整数组”由来自不同来源的高级自定义字段构建。这不是WordPress中固有的格式。
如果要为具有所有正确属性的图像输出图像标记,只需使用IDwp_get_attachment_image(). 返回HTML<img> 贴上标签src, width, height, alt, srcset, sizes 和class 全部填充。可以使用第4个参数向标记添加或更改属性:
echo wp_get_attachment_image(
$attachment_id,
\'large\',
false
[
\'class\' => \'custom-class\',
\'data-attribute\' => \'custom-attribute-value\',
]
);
老实说,如果你的目标是最终获得
<img> 标记,则即使使用ACF,也应返回ID并使用此函数。