这是ACF Gallery的php代码
<?php
$gallery = get_field('slider_1_gallery');
if( $gallery ):
?>
<div class="big_slider">
<?php foreach( $gallery as $index=>$image ): ?>
<div class="slide">
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
</div>
<?php endforeach; ?>
</div>
<div class="miniature_slider">
<?php foreach( $gallery as $index=>$image ): ?>
<div class="slide">
<a href="<?php echo $image['url']; ?>" class="miniature" data-fancybox = "1">
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
<div class="mask">
<i class="icon_1"></i>
</div>
</a>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
缩略图具有默认大小。但是我需要为此图片自定义尺寸
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
如何设置 宽度= 165像素 高度= 110像素 在ACF Gallery中? 规模和作物可能做到这一点吗?
答案 0 :(得分:0)
如果要提供自定义大小,则将此代码添加到function.php:
<?php
$attachment_id = get_field('bio_image');
$size = "people-img"; // (thumbnail, medium, large, full or custom size)
$image = wp_get_attachment_image_src( $attachment_id, $size );
// url = $image[0];
// width = $image[1];
// height = $image[2];
?>
<img src="<?php echo $image[0]; ?>" >
之后,您需要像这样获取:
{{1}}