:movie_camera: Probably the best angular inline and modal image gallery combined...
1 person uses it
Author: 5711821?v=3 thatisuday


Angular directive for image gallery in modal with thumbnails or inline like carousel



  1. AngularJS
  2. ngAnimate

Make sure you load all dependencies before loading ng-image-gallery files



→ using bower or npm

Include angular.min.js and angular-animate.min.js from bower components.

Include ng-image-gallery.min.js and ng-image-gallery.min.css from dist folder of this repository.

Include icons from res folder of this repository.

Include hammer.js for touch support (optional).

→ Manual

  1. Install AngularJS or include <script src=""></script>
  2. Install ngAnimate or include <script src=""></script>
  3. Include ng-image-gallery.min.js and ng-image-gallery.min.css from dist folder of this repository.
  4. Include icons from res folder of this repository.
  5. Include hammer.js from (optional).


Add module to your app's dependencies.

Create image gallery

You can also use <div ng-image-gallery ...></div> approach.

Set options in config phase

You can set up ng-image-gallery options once and for all using ngImageGalleryOptsProvider.

See runtime options for explanation

Set options in runtime (attributes)

1. images

images is a JavaScript array that contains objects with image url(s) of the images to be loaded into the gallery. This object can be dynamic, means images can be pushed into this array at any time. This array looks like below...

thumbUrl is not absolutely necessary. If thumbUrl url is empty, thumbnail will use url instead to show preview.

extUrl is also optional, it is external link of current image. An `external link' icon with anchor link will be added beside close button.

title and alt tags are also optional.

2. methods (optional)

methods is a communication gateway between your app and image gallery methods. It's a JavaScript object which can be used to open or close the modal as well as change images inside gallery using prev and next key. This can be done as follows...

3. thumbnails (optional) [default : true]

thumbnails attribute is used when you need to generate thumbnails on the page of the gallery images. When user clicks on any thumbnail, gallery modal is opened with that image as visible image.

4. inline (optional) [default : false]

inline attribute is used when you need to inline image gallery instead in modal. When gallery is inline, no thumbnails will be generated and gallery will be launched automatically.

5. img-bubbles (optional) [default : false]

To create image bubbles instead of simple circles. by default, bubble image url will be thumbUrl or url. But you can also add bubbleUrl (of small sizes images) to minimize request playload.

Not recommend if bubbles url defaults to url as it will download heavy images all at once.

6. bg-close (optional) [default : false]

close gallery on background click. This can be very sensitivity in mobile devices. This will not work in inline gallery.

7. bubbles (optional) [default : true]

Turn on/off bubbles.

8. img-anim (optional) [default : 'fadeup']

Set animation for image transition. Possible animation classes : fade, fadeup, zoom, slide, pop, revolve.

9. conf

conf attribute contains JavaScript object (bound to scope) which override following options.

| property name | alias for | | ---------------- | --------- | |thumbnails|thumbnails| |inline|inline| |bubbles|bubbles| |imgBubbles|img-bubbles| |bgClose|bg-close| |imgAnim|img-anim|

Not a big fan of inline options, use conf $scope.conf = { thumbnails : true, inline : false, bubbles : true, imgBubbles : false, bgClose : false, imgAnim : 'fadeup' };

10. on-open (optional) [default : noop]

This is the callback function that must be executed after gallery modal is opened. Function in the controller will look like below

11. on-close (optional) [default : noop]

Similar to on-open attribute but will be called when gallery modal closes.

Touch support

  • swipe right for prev
  • swipe left for next
  • doubletap to close gallery

Touch will be enabled only if hammer.js file is added.


When gallery is inline

  1. Do not open gallery manually, it will be automatically launched inline in the page.
  2. Default dimensions of inline gallery is 100% by 300px. Make sure to customize it as per your needs on .ng-image-gallery-modal class inside .ng-image-gallery.inline class.
  3. Do not use callbacks on inline gallery as it is useless to do so at least on open and close events.
  4. By default, close button is hidden in inline gallery as it makes no sense.


  1. Provide support for thumbnail generation.
  2. Dynamic population of images at any time.
  3. Lazy-loading of images, meaning... loading animation will be showed in the gallery until image is downloaded.
  4. jQuery independent.
  5. Smooth animations.
  6. Keypress support.
  7. Responsive (using css flexbox) with touch support.
  8. Image theft protection (simple way)
  9. Total control on gallery from outside world.
  10. Inline + Modal gallery, awesome combo.

Build on your own

You can build this directive with your own customization using gulp.

  1. Go to repository's parent directory and install all node dev dependencies using npm install --dev.
  2. Make sure you have gulp install globally. Else use npm install -g gulp to install gulp globally.
  3. All css for this repository has been generated using sass (.scss), so you need to spend 5 mins to learn basics of sass.
  4. To build or watch the changes, use command gulp build or gulp watch

Contributions and Bug reports

  1. Please create an issue if you need some help or report a bug.
  2. Take a pull request to add more features or fix the bugs. Please mention your changes in the PR.
  3. Please make sure you recommend good practices if you came/come across any or if something could have been better in this module.
comments powered by Disqus
This page was last updated almost 2 years ago.