WordPress.org

Support

Support » Plugins and Hacks » [Plugin: NextGEN Custom Fields] How to make thumbnails in sidebar link to post?

[Plugin: NextGEN Custom Fields] How to make thumbnails in sidebar link to post?

  • Hi,

    I’m using the NextGEN Gallery widget to display a gallery in my sidebar and I want to link these thumbnails directly to a url rather than the original sized picture.

    I’ve created a custom field called ‘link’ using the NextGEN Custom Field plugin as instructed to do here.

    Ive worked out the which line of .php needs editing and tried using the same code as the guide above but to no luck.

    In nextgen-gallery/widgets/widgets.php

    if (is_array($imageList)){
    			foreach($imageList as $image) {
    				// get the URL constructor
    				$image = new nggImage($image);
    
    				// get the effect code
    				$thumbcode = $image->get_thumbcode("sidebar_".$number);
    
    				// enable i18n support for alttext and description
    				$alttext      =  htmlspecialchars( stripslashes( nggGallery::i18n($image->alttext) ));
    				$description  =  htmlspecialchars( stripslashes( nggGallery::i18n($image->description) ));
    
    				//TODO:For mixed portrait/landscape it's better to use only the height setting, if widht is 0 or vice versa
    			<strong>	$out = '<a href="' . $image->ngg_custom_fields["link"] . '" title="' . $description . '" ' . $thumbcode .'>'; </strong>

    Using $image->ngg_custom_fields[“link”] doesn’t work as none of the defined links appear, all images link to http://unwantedsound.co.uk – my website.

    Can anyone help?

    Thanks in advance.

    Aaron

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey Aaron

    The widgets don’t call the function that adds custom fields to the $image object.
    You can call the function nggcf_get_field() instead. It takes the image id and the 1st argument, and the field name as the 2ndargument.

    I do not have an install of WP handy, but I think the syntax will be nggcf_get_field($image->pid, "link")

    I am heading away on holiday for 2 weeks, and won’t be around a computer for most of the time (yay me), so I hope you can get this working 🙂

    Thanks Shauno, worked perfectly.

    Have a great holiday! Hope your not coming to the UK though…awful weather!

    Cheers!

    Hey Aaron,

    I’m trying to accomplish this same thing and not having any luck. I tried the solution here and its not working for me. I inserted nggcf_get_field($image->pid, “link”) in the widgets.php file, in the same line as above. It’s still just linking back to my site. Any help or advise would be appreciated!

    Thanks!

    Brandon

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: NextGEN Custom Fields] How to make thumbnails in sidebar link to post?’ is closed to new replies.
Skip to toolbar