PDA

View Full Version : Resolved enabletitle:no in Image Thumbnail Viewer II



jscheuer1
09-26-2010, 11:38 PM
1) Script Title: Image Thumbnail Viewer II

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/thumbnail2.htm

3) Describe problem: If we set enabletitle:no in the rev attribute of a trigger, the title of that link is still shown as a description/caption of the enlarged image. This is in contradiction of (from the demo page):


enabletitle: yes|no "yes" enabletitle is set to "yes" by default, with the effect being that if your thumbnail link carries a "title" attribute, the script will use that to show a description beneath the enlarged image:

<a href="myimages/first.jpg" title="This is a picture of my dog!" rel="enlargeimage" rev="targetdiv:loadarea">Thumbnail</a>

To stop a description from showing, either set enabletitle to "no" or simply remove the "title" attribute from the thumbnail.

That's because of this highlighted line in the script:


/*Image Thumbnail Viewer II (May 19th, 2010)
* This notice must stay intact for usage
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code
*/

jQuery.noConflict()

jQuery.thumbnailviewer2={
loadmsg: '<img src="spinningred.gif" /><br />Loading Large Image...', //HTML for loading message. Make sure image paths are correct

/////NO NEED TO EDIT BEYOND HERE////////////////

dsetting: {trigger:'mouseover', preload:'yes', fx:'fade', fxduration:500, enabletitle:'yes'}, //default settings
buildimage:function($, $anchor, setting){
var imghtml='<img src="'+$anchor.attr('href')+'" style="border-width:0" />'
if (setting.link)
imghtml='<a href="'+setting.link+'">'+imghtml+'</a>'
imghtml='<div>'+imghtml+((setting.enabletitle && $anchor.attr('title')!='')? '<br />'+$anchor.attr('title') : '')+'</div>'
return $(imghtml)
},

showimage:function($image, setting){
$image.stop()[setting.fxfunc](se . . .

Notice that because of the way the red condition in it is stated, regardless of how that is set 'yes' or 'no' (both strings), it will evaluate as true.

To fix it, change that line to (addition highlighted):


imghtml='<div>'+imghtml+((setting.enabletitle !== 'no' && $anchor.attr('title')!='')? '<br />'+$anchor.attr('title') : '')+'</div>'

ddadmin
09-27-2010, 04:40 AM
Thanks, .js file updated with the fix. :)