WordPress.org

Forums

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

  1. unwantedsound
    Member
    Posted 5 years ago #

    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

  2. shauno
    Member
    Posted 5 years ago #

    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 :)

  3. unwantedsound
    Member
    Posted 5 years ago #

    Thanks Shauno, worked perfectly.

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

    Cheers!

  4. brandonvara
    Member
    Posted 4 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic