I am trying to show an image at a certain size within a repeater field which then loads within Fancybox upon click.
I can get the image to load but not at the custom size. I am not sure where I am going wrong. Please could someone give me some advice.
The URL is here: wrdtempsite.com.au/da/gallery/
Note: When I uncomment the first 3 lines, it breaks the image totally. Nothing shows.
< ?php //$attachment_id = get_sub_field('gallery_image'); //$size = "latest-news-img"; // (thumbnail, medium, large, full or custom size) //$image = wp_get_attachment_image_src( $attachment_id, $size ); ?>
I ended up using this code that works great:
$attachment_id = get_sub_field('gallery_image'); $size_thumb = "gallery-img"; // (thumbnail, medium, large, full or custom size) $size_gallery = "full"; // (thumbnail, medium, large, full or custom size) $image_thumb = wp_get_attachment_image_src( $attachment_id, $size_thumb ); $image_gallery = wp_get_attachment_image_src( $attachment_id, $size_gallery ); // url = $image; // width = $image; // height = $image; ?> <div class="gallery-img"> <img alt="Dance Avenue" src="<?php echo $image_thumb; ?>" /> <div class="enlarge-img"> <?php echo '<a class="fancybox" rel="group-'.get_the_ID().'" href="'; echo $image_gallery; echo '">View Images</a>'; ?> </div>
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!
#CodeTidbits30 Day 28 🎄— Samantha Ming (@samantha_ming) December 28, 2019
One thing that doesn't get talk often is Flexbox with Auto Margins. Although not a Flexbox property, it can be used to align child elements. Which is great for creating layouts 💯#Codenewbie #100DaysOfCode #301DaysOfCode pic.twitter.com/PmRYyBSTjr
© 2020 Advanced Custom Fields. Subscribe