• I want to be able to add class names to the thumbnails by using the comma separated tags list. I am implementing some javascript sorting using ISOTOPE which needs me to be able to identify each image using a series of classes.

    I have already created a template file called gallery-isotope so that i can make these changes and not lose them.

    For example if I had added the tags {TAG1, TAG2, TAG3} to an image, I would want to pull them out and add them into the code as shown below.

    <!-- Thumbnails -->
    	<?php foreach ( $images as $image ) : ?>
    
    	<div id="ngg-image-<?php echo $image->pid ?>" class="ngg-gallery-thumbnail-box" <?php echo $image->style ?> >
    		<div class="ngg-gallery-thumbnail TAG1 TAG2 TAG3" >
    			<a href="<?php echo $image->imageURL ?>" title="<?php echo $image->description ?>" <?php echo $image->thumbcode ?> >
    				<?php if ( !$image->hidden ) { ?>
    				<img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" <?php echo $image->size ?> />
    				<?php } ?>
    			</a>
    		</div>
    	</div>

    I don’t know how to look up the list of tags for each image, and how to then echo them out into the correct spot.

    I would really appeciate the help, if you can tell me how to do this.

    I think that it would be a useful feature to add a ‘custom class’ section (kinda like the tags thing) so you could add comma separated classes as default functionality for this plugin.

Viewing 1 replies (of 1 total)
  • Thread Starter gearu

    (@gearu)

    I managed to create a new template for Nextgen that will set up the tags required for ISOTOPE.

    in answer to my question above this code achieved what I needed:

    <?php
    //Get the TAGS for this image
    $tags = wp_get_object_terms($image->pid,'ngg_tag');
    $tag_string = ''; //store the list of strings to be put into the class menu for isotpe filtering
    ?>
    <?php foreach ( $tags as $tag ) : ?>
       <?php $tag_string = $tag_string.$tag->slug.' ';
       //alternativley can use $tag->name; which will give
       //slug with hyphen between words ?>
    <?php endforeach; ?>

    Below is the full code i have used for the Nextgen gallery template.
    view code on pastebin.com

Viewing 1 replies (of 1 total)
  • The topic ‘Nextgen Gallery – adding class to thumnail based on Tags?’ is closed to new replies.