It would be nice if an imageCache suffixed "... link to Node" or "... link to Image" was selected, to do just that.
If set, this should override the Link field. Another useability bonus could be that the user places "" in the Link field's URL field, then that will trigger the "Linked to Node" functionality...

in the mean-time, I need this ability by tomorrow, and since I try not to alter contributed module I want to change... I just created a Drupal behavior that handles this ability. Well, in a way...

To use, just add this to your Theme's js. Note, you must add the class ".image-linked-to-node" to your View's CSS field for this to work.

/**
 * Overrides Nivo Slider Module's behavior to provide
 * it with image clickability to it's node.
 * Useage: Add Views CSS Class: 'image-linked-to-node'.
 *
 */
var previous_views_nivo_sliderBehavior = Drupal.behaviors.views_nivo_sliderBehavior;
Drupal.behaviors.views_nivo_sliderBehavior = function(){
	var $sliders = $('.view.image-linked-to-node .views-nivo-slider')
	.css('cursor', 'pointer');
	function setLinks() {
		var toolClicked = false;
		$sliders.each(function(){
			var $this = $(this);
			var href = $this.find('.nivo-caption a').attr('href');
			$this.unbind('click.nivoClick')
			.bind('click.nivoClick', function(){
				if(!toolClicked) {
					window.location.href = Drupal.settings.basePath+href;
					toolClicked = false;
				}
			});
		})
		.find('.nivo-caption, .nivo-directionNav, .nivo-controlNav')
		.unbind('click.nivoClick')
		.bind('click.nivoClick', function(){
			toolClicked = true;
		});
	}
	$.each(Drupal.settings.views_nivo_slider, function(){
		this.afterChange = setLinks;
	});
	previous_views_nivo_sliderBehavior();
	setLinks();
}

Comments

Josephnewyork’s picture

Another note: To get above to work you must have what ever field your using for the caption to be "linked to its node" in the Views' settings.

* Another request would be to have the title/caption link to what the Link field is set to. I believe this should not be feature request, but a task or bug. Currently when the Link field is set, it links the image and not the caption... I believe I will have to add a behavior to this as well as this is another ability I need by tomorrow...

Edit:
Below is the updated behavior that handles both problems. To enable to a View either add 'image-linked-to-node' or 'title-linked-to-link' to the View's classes and it will handle the rest.

/**
 * Overrides Nivo Slider Module's behavior to provide
 * it with image clickability to it's node either from
 * the image or caption.
 * Useage: Add either Views CSS Classes:
 *  'image-linked-to-node'
 *  'title-linked-to-link'
 *
 */
var previous_views_nivo_sliderBehavior = Drupal.behaviors.views_nivo_sliderBehavior;
Drupal.behaviors.views_nivo_sliderBehavior = function(){
	var $slidersImage = $('.view.image-linked-to-node .views-nivo-slider')
	.css('cursor', 'pointer');
	function setImageLinks() {
		var event = 'nivoImageClick';
		var toolClicked = false;
		$slidersImage.each(function(){
			var $this = $(this);
			var href = $this.find('.nivo-caption a').attr('href');
			$this.unbind('click.'+event)
			.bind('click.'+event, function(){
				if(!toolClicked) {
					window.location.href = Drupal.settings.basePath+href;
					toolClicked = false;
				}
			});
		})
		.find('.nivo-caption, .nivo-directionNav, .nivo-controlNav')
		.unbind('click.'+event)
		.bind('click.'+event, function(){
			toolClicked = true;
		});
	}
	var $slidersTitle = $('.view.title-linked-to-link .views-nivo-slider');
	function setTitleLinks() {
		var event = 'nivoTitleClick';
		$slidersTitle.each(function(){
			var $this = $(this);
			var href;
			$this.find('.nivo-imageLink').each(function(){
				if($(this).css('display')=='block') {
					href = $(this).attr('href');
				}
			});
			$this.find('.nivo-caption').unbind('click.'+event)
			.css('cursor', 'pointer')
			.bind('click.'+event, function(){
				window.location.href = href;
			});
		});
	}
	if(Drupal.settings.views_nivo_slider) {
		$.each(Drupal.settings.views_nivo_slider, function(){
			this.afterChange = function() {
				setImageLinks();
				setTitleLinks();
			}
		});
		previous_views_nivo_sliderBehavior();
		setImageLinks();
		setTitleLinks();
	}
}

Side note:
Being that I'm using behaviors for this, this may have some multi-trigger calls that occur when any behavior triggers occur other than document.load. For example, popup doms, AJAX calls, etc. I kept this in mind when coding but haven't tested it to this situation.