Home › Forums › Add-ons › Gallery Field › Custom image size
Hi,
i am using this code to call gallery:
<?php
$images = get_field('project_gallery');
if( $images ): ?>
<?php foreach( $images as $image ): ?>
<li>
<img src="<?php echo $image['sizes']['galleryImage']; ?>" alt="">
<a href="<?php echo $image['url']; ?>" class="project-caption"><span>+</span></a>
</li>
<!-- // slider -->
<?php endforeach; ?>
<?php endif; ?>
Thumbnails have custom size and thats ok, but i want to set custom size for URL image as well. Dont want to have too big images on click. How can i achieve that?
Thanks
Create another custom image size in WP and then use that size image to link to.
I created new image size, but how to put in image code?
<a href="<?php echo $image['url']; ?>" class="project-caption"><span>+</span></a>
it says URL. thats full size image
The same way your added the custom image URL to the image tag above it
<img src="<?php echo $image['sizes']['galleryImage']; ?>" alt="">
<a href="<?php echo $image['sizes']['OtheCustomImageSize']; ?>" class="project-caption"><span>+</span></a>
When in doubt, you can always output the entire image array to see what’s in it
echo '<pre>'; print_r($image); echo '</pre>';
Thanks ! its working. I tried myself before, same solution but probably i made some error. Thanks again!
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.