View Full Version : Make your "Simple Controls Gallery v1.4" Stretch Images to Fit

Enmanuel Soria
01-25-2012, 06:22 AM
Ok people i've been playing a bit with some scripts, and found some little tricks i though you may consider interesting so i'll post them here in hopes someone else can put it into use too.

1) Script Title: Simple Controls Gallery v1.4

2)Script URL (on DD):

3) Describe problem:
the original script requires you to get images of about the same size, if you put a image too big it will only show the upper left corner

4) how to fix it:

we can take advantage of the css default Stretch in order to change this behaviour, you only need to to edit 3 lines inside the "simplegallery.js", for better results well use the gallery height to scale the images.

first the css for each image file is set in line 192 we only have to add the height.

change your line 192 from this:

layerHTML+='<img src="'+imgelement[0]+'" style="border-width:0" />'

to this:

layerHTML+='<img src="'+imgelement[0]+'" style="border-width:0;height:'+height+'px;" />'

now we need to get that height from somewhere, inside setting.dimensions[1] is the gallery height set when the gallery was created, but we dont have access to that var from this position so we will add another parameter to this function.

change your line 190 from this:


to this:


lastly we only have to change the calls to this function, there is only one in the line 139

change your line 139 from this:


to this:


and now youre done enjoy. :D