diff options
-rw-r--r-- | lib/gallery.common.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 53c2fafb..317a73e7 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -58,14 +58,16 @@ * @param elementID The image container's ID */ $.fn.gallery_fit_photo = function() { - var container_width = $(this).width(); - var photo = $(this).gallery_get_photo(); - var photo_width = photo.width(); - if (container_width < photo_width) { - var proportion = container_width / photo_width; - photo.width(container_width); - photo.height(proportion * photo.height()); - } + return this.each(function(i) { + var container_width = $(this).width(); + var photo = $(this).gallery_get_photo(); + var photo_width = photo.width(); + if (container_width < photo_width) { + var proportion = container_width / photo_width; + photo.width(container_width); + photo.height(proportion * photo.height()); + } + }); }; /** |