WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Gallery
gallery template example: thumbnail alttext captions (3 posts)

  1. electrolund
    Member
    Posted 3 years ago #

    Hey everyone, after searching long and wide, I figured out how to make my own gallery template for the excellent NextGen gallery. Based on the meager help over on the official page's template guide, I copied the plugin's gallery-caption.php file and made one simple change. This preinstalled template inserts the full Description (variable name is "caption") field from your photo's description underneath the thumbnail of each photo. For me, I use a longer description of my photos in this field, and a shorter title in the AltText field. Thus, I preferred to have alttext show up under my thumbs, not caption. Here is the code:

    <?php
    /**
    Template Page for the gallery overview
    
    Follow variables are useable :
    
    	$gallery     : Contain all about the gallery
    	$images      : Contain all images, path, title
    	$pagination  : Contain the pagination content
    
     You can check the content when you insert the tag <?php var_dump($variable) ?>
     If you would like to show the timestamp of the image ,you can use <?php echo $exif['created_timestamp'] ?>
    **/
    ?>
    <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($gallery)) : ?>
    
    <div class="ngg-galleryoverview" id="<?php echo $gallery->anchor ?>">
    
    <?php if ($gallery->show_slideshow) { ?>
    	<!-- Slideshow link -->
    	<div class="slideshowlink">
    		<a class="slideshowlink" href="<?php echo $gallery->slideshow_link ?>">
    			<?php echo $gallery->slideshow_link_text ?>
    		</a>
    	</div>
    <?php } ?>
    
    <?php if ($gallery->show_piclens) { ?>
    	<!-- Piclense link -->
    	<div class="piclenselink">
    		<a class="piclenselink" href="<?php echo $gallery->piclens_link ?>">
    			<?php _e('[View with PicLens]','nggallery'); ?>
    		</a>
    	</div>
    <?php } ?>
    
    	<!-- 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" >
    			<a href="<?php echo $image->imageURL ?>" title="<?php echo $image->description ?>" <?php echo $image->thumbcode ?> >
    				<?php if ( !$image->hidden ) { ?>
    				<img title="<?php echo $image-><b>alttext</b> ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" <?php echo $image->size ?> />
    				<?php } ?>
    			</a>
    			<span><?php echo $image->alttext ?></span>
    		</div>
    	</div>
    	<?php if ( $image->hidden ) continue; ?>
    	<?php if ( $gallery->columns > 0 && ++$i % $gallery->columns == 0 ) { ?>
    	<br style="clear: both" />
    	<?php } ?>
     	<?php endforeach; ?>
    
    	<!-- Pagination -->
     	<?php echo $pagination ?>
    
    </div>
    
    <?php endif; ?>

    Save this as "gallery-alttext.php" into this directory:
    /wp-content/themes/<your theme directory>/nggallery/gallery-sample1.php

    where "<your theme directory>" is whatever theme you are using. That's it! Here's an example of it working!

    http://wordpress.org/extend/plugins/nextgen-gallery/

  2. Strategerizer
    Member
    Posted 3 years ago #

    Interesting, though I find that the NGG template "caption" does this by default - displays the alttext, not the long description.

    Using the shortcode [nggallery id=1 template=caption] does display the short title for me, not the long description.

    I am wondering though if you may have an answer to a similar issue I am facing. I use the NGG slideshow since I don't care for the CoolIris links going to another site when using PicLens. Everything works great except that the text displayed in the slideshow is the long description, rather than the short title. Not only that, but the longer text pushes the navigation (and full screen mode) buttons out so they no longer are accessible.

    Would you know what I need to change to have the flash player show the short title instead of the long description?

    Thanks!

  3. electrolund
    Member
    Posted 3 years ago #

    Strategerizer, interesting that you found alttext displays by default. Perhaps the dev changed this in a recent release?

    I don't have much experience with the sidebar options. I do remember a while back that the alttext would not display in the sidebar widget, despite my efforts.

    I looked at the /view folder of the plugin but didn't even see a sidebar or widget PHP file, from which to start making changes. Hmm, I'll have to do some more digging for you...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.