How can I make image_crop with the Galleria jQuery plugin different if the image is wider vs taller? -


essentially want change variable image crop depending on dimensions of each image in gallery. if image's height greater width want switch height crop, else keep width crop. using galleria plugin far have code:

if ($(image).width() > $(image).height()){   var upordown = "width" } else {         var upordown = "height" } 

an variable here , part of list of options galleria:

 image_crop : upordown, 

any appreciated.

are looking way fit image inside container, without cropping? try set image_crop (or imagecrop in latest version) false.

edit: can listen loadfinish event , set options according image dimensions on fly. need call refreshimage apply changes.

$('#galleria').galleria({     extend: function() {         var gallery = this,             landscape;         this.bind('loadfinish', function(e) {             landscape = e.imagetarget.width >= e.imagetarget.height                  ? 'width' : 'height';             gallery.setoptions( 'imagecrop', landscape ).refreshimage();         });     } }); 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -