WordPress.org

Support

Support » Plugins and Hacks » Easy FancyBox » [Resolved] One thumb to gallery with ACF

[Resolved] One thumb to gallery with ACF

  • Hi there,

    I’m trying to get the one thumbnail to gallery method you’ve described in the FAQs to work with Advanced Custom Fields as opposed to NextGen. It seems like the logic should be the same, but instead of linking to the images contained in the <div class=”fancybox-hidden”> container, it only links to other thumbnails in the list.

    Here is my code :

    <?php
         $press_query = new WP_Query( array(
              'post_type' 		=> 'tp_press',
    	  'posts_per_page' 	=> 15, ) );
    		while ( $press_query->have_posts() ) {
    			$press_query->the_post();
    			$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($press_query->ID), 'full' );
    			$url = $thumb['0'];
    			$images = get_field('gallery', $press_query->ID);
    ?>
                           <a href="<?php echo $url; ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
                           <div class="fancybox-hidden">
                                <?php if( $images ) {
    	                          foreach( $images as $image ) { ?>
                                          <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
                               <?php } } ?>
                           </div>
     <?php } ?>

    Thoughts?
    thnx!
    -jennyb

    https://wordpress.org/plugins/easy-fancybox/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Ha! Just after publishing this it dawns on me that the gallery images needs hrefs – and BAM, works!

    Ok, new question: is there a way to display thumbnails of the images contained in the gallery within the modal window? I’ve seen this used with prettyphoto and it’s pretty snazzy.

    thanks again,
    -jennyb

    Ok, still having trouble though because whereas my gallery images are displaying in the modal window, they are still attached to the other thumbnails in my list. Ideally I only want the gallery images specific to each thumbnail available at one time…

    Ideas?
    thnx,
    -jennyb

    Ok, got the grouping sorted by disabling auto-gallery and adding rel=”gallery-<?php echo $post->ID; ?>” to my links.

    Still open for ideas on thumbnails!

    best,
    -jennyb

    Plugin Author RavanH

    @ravanh

    Ha! Just after publishing this it dawns on me that the gallery images needs hrefs

    Yes, it is on links that FancyBox works, not the images themselves. In fact, you can even remove the part <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> from the loop since that is embedding an image inside a hidden div anyway. Only the link tag is necessary (in which case you will not even need the hidden div anymore) …

    Ok, new question: is there a way to display thumbnails of the images contained in the gallery within the modal window?

    That will not be possible since the FancyBox 1.3.4 script that is used in this plugin was not built that way. There is a newer FancyBox version but the licence prevents it from being included in a plugin that is hosted on WordPress.org

    Ok, got the grouping sorted by disabling auto-gallery and adding rel=”gallery-<?php echo $post->ID; ?>” to my links.

    Yes, best approach 🙂

    Bummer on the FancyBox license! Ok, thanks 🙂
    best,
    -jennyb

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] One thumb to gallery with ACF’ is closed to new replies.
Skip to toolbar