View Full Version : Thumbnail viewer modification troubles

12-11-2008, 03:58 PM
1) Script Title: image thumbnail viewer

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

3) Describe problem: Hi, I've been using the script for a couple of days and it works great but when I have a particularly long description for an image, it makes the box very wide, sometimes wider than the window -cutting off some of the text as a result. I know there is probably a simle thing to do to specify the max width of description but I'm not sure how. Can anyone provide the code that I should insert into the script? Many thanks!

12-11-2008, 04:23 PM
In the script, replace the loadimage:function(link) with this one:

loadimage:function(link){ //Load image function that gets attached to each link on the page with rel="thumbnail"
if (this.thumbBox.style.visibility=="visible") //if thumbox is visible on the page already
this.closeit() //Hide it first (not doing so causes triggers some positioning bug in Firefox
var imageHTML='<img src="'+link.getAttribute("href")+'" style="'+this.opacitystring+'" />' //Construct HTML for shown image
if (this.enableTitle && link.getAttribute("title")) //Use title attr of the link as description?
imageHTML+='<br />'+link.getAttribute("title")
this.centerDiv(this.thumbLoading) //Center and display "loading" div while we set up the image to be shown
this.thumbImage.innerHTML=imageHTML //Populate thumbImage div with shown image's HTML (while still hidden)
this.featureImage=this.thumbImage.getElementsByTagName("img")[0] //Reference shown image itself
if (this.featureImage.complete){
this.thumbImage.style.width = this.featureImage.width + 'px';
this.featureImage.onload=function(){ //When target image has completely loaded
thumbnailviewer.thumbImage.style.width = thumbnailviewer.featureImage.width + 'px';
thumbnailviewer.showthumbBox() //Display "thumbbox" div to the world!
if (document.all && !window.createPopup) //Target IE5.0 browsers only. Address IE image cache not firing onload bug: panoramio.com/blog/onload-event/
this.featureImage.onerror=function(){ //If an error has occurred while loading the image to show
thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div, game over

12-11-2008, 07:19 PM
that's great I'll do that, thanks very much!:)