Results 1 to 2 of 2

Thread: fadeshow auto resize image

  1. #1
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default fadeshow auto resize image

    1) Script Title: fadeshow

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...nslideshow.htm

    3) Describe problem: I cannot figure out how to force the image to resize to the fadewidth and/or fadeheight set in the script.

    I need to be able to force the image size to the same width as the fadeshow box, but allow the height to dynamically resize proportionately to the width. This is easy in HTML by using <img src="images/title07.gif" alt="Contact" width="166">. This takes an image of any size and forces it to be 166px wide and dynamically resizes the hight to be the proportional hight so the image is not distorted.

    Thanks in advance!
    ~Randy

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This is a bad idea. It is much better to resize your images in an image editing program, and to optimize them. This is the web after all, and performance counts.

    However, if you insist upon doing this, find this function in the script and add the red part:

    Code:
    fadeshow.prototype.populateslide=function(picobj, picindex){
    var slideHTML=""
    if (this.theimages[picindex][1]!="") //if associated link exists for image
    slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
    slideHTML+='<img width="166" src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
    if (this.theimages[picindex][1]!="") //if associated link exists for image
    slideHTML+='</a>'
    picobj.innerHTML=slideHTML
    }
    If you need it to adapt to the width you set in the call (like if you are doing this more than once on a page and the width is different in different slide shows), you can do:

    Code:
    fadeshow.prototype.populateslide=function(picobj, picindex){
    var slideHTML=""
    if (this.theimages[picindex][1]!="") //if associated link exists for image
    slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
    slideHTML+='<img width="'+this.fadewidth+'" src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
    if (this.theimages[picindex][1]!="") //if associated link exists for image
    slideHTML+='</a>'
    picobj.innerHTML=slideHTML
    }
    instead, but you will also have to add (as shown in red):

    Code:
    function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
    this.fadewidth=fadewidth
    this.pausecheck=pause
    this.mouseovercheck=0
    this.delay=delay
    this.degree=10 //initial opacity degree (10%)
    this.curimageindex=0
    this.nexti . . .
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •