• beernews

    (@beernews)


    The fix: Replace lines 403 to 428 or

    if (is_array($imageList)){
    -to-
    $nggWidget = new nggWidget;

    of nggwidget.php with the following code:

    if (is_array($imageList)){
    			foreach($imageList as $image) {
    
    	$maxElement = $ngg_options['galImages'];
    	$thumbwidth = $ngg_options['thumbwidth'];
    	$thumbheight = $ngg_options['thumbheight'];
    
    // set thumb size
    	$thumbsize = "";
    		if ($ngg_options['thumbfix'])  $thumbsize = 'style="width:'.$thumbwidth.'px; height:'.$thumbheight.'px;"';
    		if ($ngg_options['thumbcrop']) $thumbsize = 'style="width:'.$thumbwidth.'px; height:'.$thumbwidth.'px;"';
    
    // get the effect code
    		if ($galleryID)
    		$thumbcode = ($ngg_options['galImgBrowser']) ? "" : nggallery::get_thumbcode($imagelist[0]->name);
    	else
    		$thumbcode = ($ngg_options['galImgBrowser']) ? "" : nggallery::get_thumbcode(get_the_title());
    
    // show slideshow link
    	if ($galleryID)
    		if (($ngg_options['galShowSlide']) AND (NGGALLERY_IREXIST)) {
    			$args['show'] = "slide";
    			$out .= '<div class="slideshowlink"><a class="slideshowlink" href="' . $nggRewrite->get_permalink($args) . '">'.$ngg_options['galTextSlide'].'</a></div>';
    		}
    
    // a description below the picture, require fixed width
    	if (!$ngg_options['galShowDesc'])
    	$ngg_options['galShowDesc'] = "none";
    	$setwidth = ($ngg_options['galShowDesc'] != "none") ? 'style="width:'.($thumbwidth).'px;"' : '';
    	$class_desc = ($ngg_options['galShowDesc'] != "none") ? 'desc' : '';
    
    // set image url
    		$folder_url 	= get_option ('siteurl')."/".$image->path."/";
    		$thumbnailURL 	= get_option ('siteurl')."/".$image->path.nggallery::get_thumbnail_folder($image->path, FALSE);
    		$thumb_prefix   = nggallery::get_thumbnail_prefix($image->path, FALSE);
    
    // choose link between imagebrowser or effect
    		$link = ($ngg_options['galImgBrowser']) ? $nggRewrite->get_permalink(array('pid'=>$image->pid)) : $image->alttext;
    
    // add filter for the link
      		$link	= apply_filters('ngg_create_gallery_link', $link, $image);
    		$thumbcode2  = apply_filters('ngg_create_gallery_thumbcode', $thumbcode, $image);
    // create output
    		$out .= '<div id="ngg-image-'. $image->pid .'" class="ngg-gallery-thumbnail-box '. $class_desc .'">'."\n\t";
    		$out .= '<div class="ngg-gallery-thumbnail" '.$setwidth.' >'."\n\t";
    				$out = '<a id="thumb'.$image->pid.'" href="'.$link.'" title="'.stripslashes($image->description).'" '.$thumbcode2.'>';
    				if ($ngg_options['galShowDesc'] == "alttext")
    			$out .= '<span>'.html_entity_decode(stripslashes($image->alttext)).'</span>'."\n";
    		if ($ngg_options['galShowDesc'] == "desc")
    			$out .= '<span>'.html_entity_decode(stripslashes($image->description)).'</span>'."\n";
    if ( $options[$number]['show'] == "orginal" )
    					$out .= '<img src="'.NGGALLERY_URLPATH.'nggshow.php?pid='.$image->pid.'&amp;width='.$options[$number]['width'].'&amp;height='.$options[$number]['height'].'" title="'.$image->description.'" alt="'.$image->alttext.'" />';
    				else
    					$out .= '<img src="'.nggallery::get_thumbnail_url($image->pid).'" style="width:'.$options[$number]['width'].'px;height:'.$options[$number]['height'].'px;" title="'.$image->description.'" alt="'.$image->alttext.'" />';		
    
    				echo $out . '</a>'."\n";
    // add filter for the output
    		$out  = apply_filters('ngg_inner_gallery_thumbnail', $out, $image);
    		$out .= '</div>'. "\n" .'</div>'."\n";
    		$out  = apply_filters('ngg_after_gallery_thumbnail', $out, $image);
    		}
    		}
    
    		echo '</div>'."\n";
     	$out .= ($maxElement > 0) ? $navigation : '<div class="ngg-clear"></div>'."\n";
    		echo $after_widget;
    
    	}
    
    }
    // let's show it
    $nggWidget = new nggWidget;

    Easy, no?

    This does not work for Slideshow widget. Someone would probably have to mess with js rotator settings there.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter beernews

    (@beernews)

    SOMEONE PLEASE FEEL FREE TO CLEAN UP MY CODE.

    What this does is now mimic the functionality that you would expect in an ad rotator plug-in. There is another one here though I have never tried it: https://blog.taragana.com/index.php/archive/wordpress-plugin-adrotator-rotate-your-ads-including-adsense-dynamically/. I’ve never used adsense and no clue how it’ll work with this. So with each pageview refresh, a new image appears in which clicking will take you to the linked website.

    Notes:

    A) Backup first, try it out on local server if you have a chance but this shouldn’t break your blog. Add link such as https://www.ads-software.com to any alt-text field in your ‘Manager Gallery’ Page and add replace the code below and enjoy.

    B) You may need to turn off any effect under NGG options to get it to work properly but try it.

    C) I also left some show description code in from nggfunctions if someone can figure out how to get it to show descriptions below the pic. I felt like I was close but no cigar.

    D) Will Google Analytics track these clicks? I think so if you have the plugin. Not sure. If not, we’ll need to figure out if the alt-text field can handle html markup and what kind of code we can put there. I would like to use the google analytics tracking code…

    boober

    (@boober)

    this works great. except the image effects do mess it up. is there a way to turn image effects off in just the widget, so they can still be used in the regular galleries?

    Thread Starter beernews

    (@beernews)

    I’m guessing you’d have to play around with the settings in nggwidget.php and the nggfunctions file to make that work. Could be an easy fix but I have no idea. I was lucky to get this working considering my limited technical expertise!

    nice work beernews, but on a somewhat related note…

    the ngg_gal_ShowDescription meta tag doesn’t seem to do anything for regular gallery displays and I found no code based on it in the plug-in. any thoughts?

    thanks!

    I think this is what I’ve been looking for but it does not seem to work in version 1.1 of NextGEN Gallery if there is an updated version of this I would love to get a hold of it Thanks.

    I tried to do this… but just crashed my site..
    luckily i backed up.. so its back up..

    But I would like to get this to work, so any help doing this would be appriciated.

    Thanks’

    I’m trying to get my nextgen gallery widget to link to the gallery pages as well…hope someone can help out ??

    Yes – I use the sidebar widget for sponsors as rotator-ads – – it would be nice to be able to link the images instead of opening the image..

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: NextGEN Gallery] Eureka! How to link to pages from sidebar gallery widget only (ad rotator)’ is closed to new replies.