I am trying to get the images to "scale to fit" the galleria wrapper
I got some variable codes to work in the jquery.gallera.js file, but they work by determining the height width ratio and setting one of two sizes to the image..for landscape and portrait. I would rather have the image scale to fit the .galleria.wrapper dimensions I set in the .css file. I found a jquery plugin that will scale images to fit a defined container here
http://code.google.com/p/jquery-imagefit-plugin/
so I download that file and drop it in the inc folder with the other script files....
im not sure how exactly to impliment this plugin into the jquery.galleria.js so that the _img will resize to fit the galleria wrapper...I have many images of many different sizes and ratios im trying to load, keeping the aspect ratios..is this a way to do it?
Thanks
David
Comments
Comment #1
rankinstudio commentedDoes anyone know the id for the main image container? Is it the galleria_wrapper?
Comment #2
cheese-steak commentedSubscribing
Comment #3
roger6106 commentedI think this would be a great feature to add to the module.
Comment #4
rankinstudio commentedAlright, I got some dynamic resizing going...here it is. you post this code in the galleria.js file right in the onimage function..
if ($(image).width() > $(image).height()){ //landscape
var ratio = ($(image).height()) / ($(image).width());
image.css('width','640px');
image.css('height','width * ratio');
}
else { // portrait
var ratio = ($(image).height()) / ($(image).width());
image.css('width','height * ratio');
image.css('height','450px');
}
You also need to set explicit height/width to your .galleria_container in the galleria.css file..here is mine.
.galleria_container {
height:450px;
width:640px;
position:relative;
top:88px;
background:url(/modules/galleria/galback.jpg);
}
you need to add that ,it does not exist in the the downloaded css. Then to center the portrait images inside of the galleria wrapper, you must add this.
.galleria_container img {
display:block;
margin-left: auto;
margin-right: auto;
}
Ive been working on this for way to long, finally got it workin...ENJOY!
David
my gallerias
http://www.rankinstudio.com/photointro
Comment #5
Mark Theunissen commentedArgh... I wouldn't do that... rather override some variables from the preprocess function and use imagecache! See the following issue:
http://drupal.org/node/350561
Comment #6
rankinstudio commentedYea, its an ugly hack, but I cant install ImageAPI have php 4 not 5:(
Comment #7
SkullSplitter commentedIt try it out too, Not working :( whats wrong ?
Thx in advance
Skull