是的,可以获得原始图像和较小版本的图像。使用wp_get_attachment_url($id)
获取完整的url和wp_get_attachment_image_src($id,$size)
对于较小的版本。
EDIT: 您可以从attachments post\\u meta获取原始未删减(完整)图像的名称。然后用完整url中的原始名称替换裁剪后的文件名<如果有更直接的方法,我洗耳恭听
比如像这样,
$image_id = 0; // get this from the saved ACF data
$full_image = wp_get_attachment_url( $image_id );
$thumbnail = wp_get_attachment_image_src( $image_id, \'thumbnail\' ); // or some other valid image size
// get original file name and replace cropped name with it
$backup_full = get_post_meta( $image_id, \'_wp_attachment_backup_sizes\', true );
if ( ! empty( $backup_full[\'full-orig\'][\'file\'] ) ) {
$full_path = explode( \'/\', $full_image );
$full_image = str_replace( end( $full_path ), $backup_full[\'full-orig\'][\'file\'], $full_image );
}
if ( $full_image && is_array( $thumbnail ) ) {
printf(
\'<div class="slide">
<a href="%s" class="mfp-image">
<img src="%s"/>
</a>
</div>\',
esc_url( $full_image ),
esc_url( $thumbnail[0] )
);
}