• Resolved SetMonkey13

    (@setmonkey13)


    I have made a custom thumbnail view at /wp-content/ngg/modules/photocrati-nextgen_basic_thumbnails/templates
    I have pages where I am showing multiple galleries on the single page and so I would like it to show the Gallery name for each image below it. I can’t figure out the code to gather that information.

    I also have a problem with a search page that is displaying the results as the thumbnails but when clicking on the thumbnails, they don’t open the imagebrowser page correctly because of the page the search is on.
    Example. should be going to /props/stools/nggallery/image/hpim3081
    but is instead going to /props/search/nggallery/image/hpim3081
    If I learn how to get the gallery name, I think I can fix the data-imagebrowser-url.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Imagely

    (@imagely)

    Hi @setmonkey13,

    To retrieve the gallery’s title you’d need a construction as below then echo the $gallery_title variable whenever you need to display the title:

    <?php foreach ($displayed_gallery->get_galleries() as $gallery): ?>
      <?php $gallery_title = esc_html($gallery->title) ?>
    <?php endforeach ?>

    As for the Frontend Search related questions – please reach our support team directly at https://www.imagely.com/support/.
    We are not allowed to discuss premium related features here in the forum.

    Thread Starter SetMonkey13

    (@setmonkey13)

    That doesn’t show the correct gallery title for each image. Just one of the gallery titles no matter what image it is.

    <?php $this->start_element('nextgen_gallery.gallery_container', 'container', $displayed_gallery); ?>
    
    <div class="ngg-galleryoverview caption-view <?php if (!intval($ajax_pagination)) echo ' ngg-ajax-pagination-none'; ?>"
    	id="ngg-gallery-<?php echo esc_attr($displayed_gallery_id)?>-<?php echo esc_attr($current_page)?>">
        <div class="ngg-caption-view-wrapper">
            <?php $this->start_element('nextgen_gallery.image_list_container', 'container', $images); ?>
                <?php
                for ($i = 0; $i<count($images); $i++) {
                    $image = $images[$i];
                    $thumb_size = $storage->get_image_dimensions($image, $thumbnail_size_name);
                    $style = isset($image->style) ? $image->style : null;
                    $column_class = 'ngg-' . $number_of_columns . '-columns';
    
                    if (isset($image->hidden) && $image->hidden) {
                        $style = 'style="display: none;"';
                    } else {
                        $style = null;
                    }
    
                    $this->start_element('nextgen_gallery.image_panel', 'item', $image);
                    ?>
                        <div id="<?php echo esc_attr('ngg-image-' . $i) ?>" class="ngg-gallery-thumbnail-box <?php if ($number_of_columns > 0 && empty($show_all_in_lightbox)) { echo $column_class; } ?>" <?php if ($style) echo $style; ?>>
                            <?php $this->start_element('nextgen_gallery.image', 'item', $image); ?>
                                <div class="ngg-gallery-thumbnail">
                                    <a href="<?php echo esc_attr($storage->get_image_url($image, 'full', TRUE))?>"
                                       title="<?php echo esc_attr($image->description)?>"
                                       data-src="<?php echo esc_attr($storage->get_image_url($image)); ?>"
                                       data-thumbnail="<?php echo esc_attr($storage->get_image_url($image, 'thumb')); ?>"
                                       data-image-id="<?php echo esc_attr($image->{$image->id_field}); ?>"
                                       data-title="<?php echo esc_attr($image->alttext); ?>"
                                       data-description="<?php echo esc_attr(stripslashes($image->description)); ?>"
                                       data-image-slug="<?php echo esc_attr($image->image_slug); ?>"
                                        <?php echo $effect_code ?>>
                                        <img title="<?php echo esc_attr($image->alttext)?>"
                                             alt="<?php echo esc_attr($image->alttext)?>"
                                             src="<?php echo esc_attr($storage->get_image_url($image, $thumbnail_size_name))?>"
                                             width="<?php echo esc_attr($thumb_size['width'])?>"
                                             height="<?php echo esc_attr($thumb_size['height'])?>"
                                             style="max-width:100%;"/>
                                    
                                    <?php echo $image->alttext ?></a><span>
                                    <br>
                                    <?php foreach ($displayed_gallery->get_galleries() as $gallery): ?>
                                        <?php $gallery_title = esc_html($gallery->title) ?>
                                        <?php endforeach ?>
                                    <?php echo $gallery_title?>
                                    <?php if (!isset($image->hidden) || !$image->hidden) { ?>
                                        <span style="max-width: <?php print esc_attr($thumb_size['width']); ?>px">
                                            <?php print $image->description; ?>
                                            
                                        </span>
                                    <?php } ?>
                                </div>
                            <?php $this->end_element(); ?>
                        </div>
                    <?php $this->end_element(); ?>
                <?php } ?>
            <?php $this->end_element(); ?>
        </div>
    
        <?php if (!empty($slideshow_link)) { ?>
            <div class="slideshowlink">
                <a href='<?php echo esc_attr($slideshow_link) ?>'><?php echo esc_html($slideshow_link_text) ?></a>
            </div>
        <?php } ?>
    
        <?php if ($pagination) { ?>
            <?php echo $pagination ?>
        <?php } ?>
    </div>
    
    <?php $this->end_element(); ?>
    Plugin Contributor Imagely

    (@imagely)

    I see. If you have many galleries as source, you may want to check for the gallery ID before displaying the title:

    
    <?php foreach ($displayed_gallery->get_galleries() as $gallery):
            if ($gallery -> gid == $image -> galleryid )
    	echo esc_html($gallery->title);
    endforeach ?>
    
    • This reply was modified 2 years, 10 months ago by Imagely.
    • This reply was modified 2 years, 10 months ago by Imagely.
    • This reply was modified 2 years, 10 months ago by Imagely.
    Thread Starter SetMonkey13

    (@setmonkey13)

    Wonderful. Thanks so much for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display Gallery name under thumbnail’ is closed to new replies.