Giter Site home page Giter Site logo

blueimp / gallery Goto Github PK

View Code? Open in Web Editor NEW
3.7K 232.0 984.0 2.32 MB

blueimp Gallery is a touch-enabled, responsive and customizable image & video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers. It features swipe, mouse and keyboard navigation, transition effects, slideshow functionality, fullscreen support and on-demand content loading.

Home Page: https://blueimp.github.io/Gallery/

License: Other

JavaScript 83.63% CSS 11.25% HTML 5.04% Shell 0.08%

gallery's Introduction

blueimp Gallery

Contents

Description

blueimp Gallery is a touch-enabled, responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.

It features swipe, mouse and keyboard navigation, transition effects, slideshow functionality, fullscreen support and on-demand content loading and can be extended to display additional content types.

Setup

Install the blueimp-gallery package with NPM:

npm install blueimp-gallery

Lightbox setup

Copy the css, img and js directories to your website.

Include the Gallery stylesheet in the head section of your webpage:

<link rel="stylesheet" href="css/blueimp-gallery.min.css" />

Add the following HTML snippet with the Gallery widget to the body of your webpage:

<!-- The Gallery as lightbox dialog, should be a document body child element -->
<div
  id="blueimp-gallery"
  class="blueimp-gallery"
  aria-label="image gallery"
  aria-modal="true"
  role="dialog"
>
  <div class="slides" aria-live="polite"></div>
  <h3 class="title"></h3>
  <a
    class="prev"
    aria-controls="blueimp-gallery"
    aria-label="previous slide"
    aria-keyshortcuts="ArrowLeft"
  ></a>
  <a
    class="next"
    aria-controls="blueimp-gallery"
    aria-label="next slide"
    aria-keyshortcuts="ArrowRight"
  ></a>
  <a
    class="close"
    aria-controls="blueimp-gallery"
    aria-label="close"
    aria-keyshortcuts="Escape"
  ></a>
  <a
    class="play-pause"
    aria-controls="blueimp-gallery"
    aria-label="play slideshow"
    aria-keyshortcuts="Space"
    aria-pressed="false"
    role="button"
  ></a>
  <ol class="indicator"></ol>
</div>

Please note that each aria-controls attribute should have the same value as the id attribute of the Gallery widget.

Include the Gallery script at the bottom of the body of your webpage:

<script src="js/blueimp-gallery.min.js"></script>

Create a list of links to image files, optionally with enclosed thumbnails and add them to the body of your webpage, before including the Gallery script:

<div id="links">
  <a href="images/banana.jpg" title="Banana">
    <img src="images/thumbnails/banana.jpg" alt="Banana" />
  </a>
  <a href="images/apple.jpg" title="Apple">
    <img src="images/thumbnails/apple.jpg" alt="Apple" />
  </a>
  <a href="images/orange.jpg" title="Orange">
    <img src="images/thumbnails/orange.jpg" alt="Orange" />
  </a>
</div>

Add the following JavaScript code after including the Gallery script, to display the images in the Gallery lightbox on click of one of those links:

<script>
  document.getElementById('links').onclick = function (event) {
    event = event || window.event
    var target = event.target || event.srcElement
    var link = target.src ? target.parentNode : target
    var options = { index: link, event: event }
    var links = this.getElementsByTagName('a')
    blueimp.Gallery(links, options)
  }
</script>

Controls

To initialize the Gallery with visible controls (previous slide, next slide, etc.), add the CSS class blueimp-gallery-controls to the Gallery widget:

<div
  id="blueimp-gallery"
  class="blueimp-gallery blueimp-gallery-controls"
  aria-label="image gallery"
  aria-modal="true"
  role="dialog"
>
  <!-- ... -->
</div>

Please also note that by default, a click on an image slide or any Gallery widget element with the toggle class will toggle the display of the Gallery controls.

Contain

To stretch smaller images to the dimensions of the Gallery container while keeping their aspect ratio, add the CSS class blueimp-gallery-contain to the Gallery widget:

<div
  id="blueimp-gallery"
  class="blueimp-gallery blueimp-gallery-contain"
  aria-label="image gallery"
  aria-modal="true"
  role="dialog"
>
  <!-- ... -->
</div>

Carousel setup

To display the images in an inline carousel instead of a lightbox, follow the lightbox setup and add the CSS class blueimp-gallery-carousel to the Gallery widget and remove the child element with the close class, or add a new Gallery widget with a different id to your webpage:

<!-- The Gallery as inline carousel, can be positioned anywhere on the page -->
<div
  id="blueimp-gallery-carousel"
  class="blueimp-gallery blueimp-gallery-carousel"
  aria-label="image carousel"
>
  <div class="slides" aria-live="off"></div>
  <h3 class="title"></h3>
  <a
    class="prev"
    aria-controls="blueimp-gallery-carousel"
    aria-label="previous slide"
  ></a>
  <a
    class="next"
    aria-controls="blueimp-gallery-carousel"
    aria-label="next slide"
  ></a>
  <a
    class="play-pause"
    aria-controls="blueimp-gallery-carousel"
    aria-label="play slideshow"
    aria-pressed="true"
    role="button"
  ></a>
  <ol class="indicator"></ol>
</div>

Add the following JavaScript code after including the Gallery script to initialize the carousel:

<script>
  blueimp.Gallery(document.getElementById('links').getElementsByTagName('a'), {
    container: '#blueimp-gallery-carousel',
    carousel: true
  })
</script>

Responsive images

The Gallery supports the concept of responsive images with the srcset, sizes and sources object properties, e.g. using the API:

var gallery = blueimp.Gallery([
  {
    title: 'Banana',
    href: 'https://example.org/images/banana-1024w.jpg',
    srcset:
      'https://example.org/images/banana-800w.jpg 800w,' +
      'https://example.org/images/banana-1024w.jpg 1024w,' +
      'https://example.org/images/banana-1600w.jpg 1600w',
    sizes: '(min-width: 990px) 990px, 100vw',
    thumbnail: 'https://example.org/images/banana-75.jpg'
  },
  {
    title: 'Apple',
    href: 'https://example.org/images/apple.png',
    sources: [
      {
        type: 'image/svg+xml',
        srcset: 'https://example.org/images/apple.svg'
      },
      {
        type: 'image/webp',
        srcset: 'https://example.org/images/apple.webp'
      }
    ]
  }
])

With link elements, those same properties can be defined via data-srcset, data-sizes and data-sources attributes:

<div id="links">
  <a
    title="Banana"
    href="images/banana-1024w.jpg"
    data-srcset="images/banana-800w.jpg 800w,
                 images/banana-1024w.jpg 1024w,
                 images/banana-1600w.jpg 1600w"
    data-sizes="(min-width: 990px) 990px, 100vw"
  >
    <img src="images/banana-75.jpg" alt="Banana" />
  </a>
  <a
    title="Apple"
    href="images/apple.png"
    data-sources='[
      {
        "type": "image/svg+xml",
        "srcset": "images/apple.svg"
      },
      {
        "type": "image/webp",
        "srcset": "images/apple.webp"
      }
    ]'
    >Apple</a
  >
</div>

Please note that data-sources must be a valid JSON string listing the sources array.

Keyboard shortcuts

The Gallery can be controlled with the following keyboard shortcuts:

  • Enter: Toggle controls visibility.
  • Escape: Close the Gallery lightbox.
  • Space: Toggle the slideshow (play/pause).
  • ArrowLeft: Move to the previous slide.
  • ArrowRight: Move to the next slide.

Please note that setting the carousel option to true disables the keyboard shortcuts by default.

Options

Default options

The following are the default options set by the core Gallery library:

var options = {
  // The Id, element or querySelector of the gallery widget:
  container: '#blueimp-gallery',
  // The tag name, Id, element or querySelector of the slides container:
  slidesContainer: 'div',
  // The tag name, Id, element or querySelector of the title element:
  titleElement: 'h3',
  // The class to add when the gallery is visible:
  displayClass: 'blueimp-gallery-display',
  // The class to add when the gallery controls are visible:
  controlsClass: 'blueimp-gallery-controls',
  // The class to add when the gallery only displays one element:
  singleClass: 'blueimp-gallery-single',
  // The class to add when the left edge has been reached:
  leftEdgeClass: 'blueimp-gallery-left',
  // The class to add when the right edge has been reached:
  rightEdgeClass: 'blueimp-gallery-right',
  // The class to add when the automatic slideshow is active:
  playingClass: 'blueimp-gallery-playing',
  // The class to add when the browser supports SVG as img (or background):
  svgasimgClass: 'blueimp-gallery-svgasimg',
  // The class to add when the browser supports SMIL (animated SVGs):
  smilClass: 'blueimp-gallery-smil',
  // The class for all slides:
  slideClass: 'slide',
  // The slide class for the active (current index) slide:
  slideActiveClass: 'slide-active',
  // The slide class for the previous (before current index) slide:
  slidePrevClass: 'slide-prev',
  // The slide class for the next (after current index) slide:
  slideNextClass: 'slide-next',
  // The slide class for loading elements:
  slideLoadingClass: 'slide-loading',
  // The slide class for elements that failed to load:
  slideErrorClass: 'slide-error',
  // The class for the content element loaded into each slide:
  slideContentClass: 'slide-content',
  // The class for the "toggle" control:
  toggleClass: 'toggle',
  // The class for the "prev" control:
  prevClass: 'prev',
  // The class for the "next" control:
  nextClass: 'next',
  // The class for the "close" control:
  closeClass: 'close',
  // The class for the "play-pause" toggle control:
  playPauseClass: 'play-pause',
  // The list object property (or data attribute) with the object type:
  typeProperty: 'type',
  // The list object property (or data attribute) with the object title:
  titleProperty: 'title',
  // The list object property (or data attribute) with the object alt text:
  altTextProperty: 'alt',
  // The list object property (or data attribute) with the object URL:
  urlProperty: 'href',
  // The list object property (or data attribute) with the object srcset:
  srcsetProperty: 'srcset',
  // The list object property (or data attribute) with the object sizes:
  sizesProperty: 'sizes',
  // The list object property (or data attribute) with the object sources:
  sourcesProperty: 'sources',
  // The gallery listens for transitionend events before triggering the
  // opened and closed events, unless the following option is set to false:
  displayTransition: true,
  // Defines if the gallery slides are cleared from the gallery modal,
  // or reused for the next gallery initialization:
  clearSlides: true,
  // Toggle the controls on pressing the Enter key:
  toggleControlsOnEnter: true,
  // Toggle the controls on slide click:
  toggleControlsOnSlideClick: true,
  // Toggle the automatic slideshow interval on pressing the Space key:
  toggleSlideshowOnSpace: true,
  // Navigate the gallery by pressing the ArrowLeft and ArrowRight keys:
  enableKeyboardNavigation: true,
  // Close the gallery on pressing the Escape key:
  closeOnEscape: true,
  // Close the gallery when clicking on an empty slide area:
  closeOnSlideClick: true,
  // Close the gallery by swiping up or down:
  closeOnSwipeUpOrDown: true,
  // Close the gallery when the URL hash changes:
  closeOnHashChange: true,
  // Emulate touch events on mouse-pointer devices such as desktop browsers:
  emulateTouchEvents: true,
  // Stop touch events from bubbling up to ancestor elements of the Gallery:
  stopTouchEventsPropagation: false,
  // Hide the page scrollbars:
  hidePageScrollbars: true,
  // Stops any touches on the container from scrolling the page:
  disableScroll: true,
  // Carousel mode (shortcut for carousel specific options):
  carousel: false,
  // Allow continuous navigation, moving from last to first
  // and from first to last slide:
  continuous: true,
  // Remove elements outside of the preload range from the DOM:
  unloadElements: true,
  // Start with the automatic slideshow:
  startSlideshow: false,
  // Delay in milliseconds between slides for the automatic slideshow:
  slideshowInterval: 5000,
  // The direction the slides are moving: ltr=LeftToRight or rtl=RightToLeft
  slideshowDirection: 'ltr',
  // The starting index as integer.
  // Can also be an object of the given list,
  // or an equal object with the same url property:
  index: 0,
  // The number of elements to load around the current index:
  preloadRange: 2,
  // The transition duration between slide changes in milliseconds:
  transitionDuration: 300,
  // The transition duration for automatic slide changes, set to an integer
  // greater 0 to override the default transition duration:
  slideshowTransitionDuration: 500,
  // The event object for which the default action will be canceled
  // on Gallery initialization (e.g. the click event to open the Gallery):
  event: undefined,
  // Callback function executed when the Gallery is initialized.
  // Is called with the gallery instance as "this" object:
  onopen: undefined,
  // Callback function executed when the Gallery has been initialized
  // and the initialization transition has been completed.
  // Is called with the gallery instance as "this" object:
  onopened: undefined,
  // Callback function executed on slide change.
  // Is called with the gallery instance as "this" object and the
  // current index and slide as arguments:
  onslide: undefined,
  // Callback function executed after the slide change transition.
  // Is called with the gallery instance as "this" object and the
  // current index and slide as arguments:
  onslideend: undefined,
  // Callback function executed on slide content load.
  // Is called with the gallery instance as "this" object and the
  // slide index and slide element as arguments:
  onslidecomplete: undefined,
  // Callback function executed when the Gallery is about to be closed.
  // Is called with the gallery instance as "this" object:
  onclose: undefined,
  // Callback function executed when the Gallery has been closed
  // and the closing transition has been completed.
  // Is called with the gallery instance as "this" object:
  onclosed: undefined
}

Event callbacks

Event callbacks can be set as function properties of the options object passed to the Gallery initialization function:

var gallery = blueimp.Gallery(linkList, {
  onopen: function () {
    // Callback function executed when the Gallery is initialized.
  },
  onopened: function () {
    // Callback function executed when the Gallery has been initialized
    // and the initialization transition has been completed.
  },
  onslide: function (index, slide) {
    // Callback function executed on slide change.
  },
  onslideend: function (index, slide) {
    // Callback function executed after the slide change transition.
  },
  onslidecomplete: function (index, slide) {
    // Callback function executed on slide content load.
  },
  onclose: function () {
    // Callback function executed when the Gallery is about to be closed.
  },
  onclosed: function () {
    // Callback function executed when the Gallery has been closed
    // and the closing transition has been completed.
  }
})

Carousel options

If the carousel option is true, the following options are set to different default values:

var carouselOptions = {
  hidePageScrollbars: false,
  toggleControlsOnEnter: false,
  toggleSlideshowOnSpace: false,
  enableKeyboardNavigation: false,
  closeOnEscape: false,
  closeOnSlideClick: false,
  closeOnSwipeUpOrDown: false,
  closeOnHashChange: false,
  disableScroll: false,
  startSlideshow: true
}

The options object passed to the Gallery function extends the default options and also those options set via carousel mode.

Indicator options

The following are the additional default options set for the slide position indicator:

var indicatorOptions = {
  // The tag name, Id, element or querySelector of the indicator container:
  indicatorContainer: 'ol',
  // The class for the active indicator:
  activeIndicatorClass: 'active',
  // The list object property (or data attribute) with the thumbnail URL,
  // used as alternative to a thumbnail child element:
  thumbnailProperty: 'thumbnail',
  // Defines if the gallery indicators should display a thumbnail:
  thumbnailIndicators: true
}

Fullscreen options

The following are the additional default options set for the fullscreen mode:

var fullscreenOptions = {
  // Defines if the gallery should open in fullscreen mode:
  fullscreen: false
}

Video options

Video factory options

The following are the additional default options set for the video factory:

var videoFactoryOptions = {
  // The class for video content elements:
  videoContentClass: 'video-content',
  // The class for video when it is loading:
  videoLoadingClass: 'video-loading',
  // The class for video when it is playing:
  videoPlayingClass: 'video-playing',
  // The class for video content displayed in an iframe:
  videoIframeClass: 'video-iframe',
  // The class for the video cover element:
  videoCoverClass: 'video-cover',
  // The class for the video play control:
  videoPlayClass: 'video-play',
  // Play videos inline by default:
  videoPlaysInline: true,
  // The list object property (or data attribute) for video preload:
  videoPreloadProperty: 'preload',
  // The list object property (or data attribute) for the video poster URL:
  videoPosterProperty: 'poster'
}

YouTube options

Options for YouTube videos:

var youTubeOptions = {
  // The list object property (or data attribute) with the YouTube video id:
  youTubeVideoIdProperty: 'youtube',
  // Optional object with parameters passed to the YouTube video player:
  // https://developers.google.com/youtube/player_parameters
  youTubePlayerVars: undefined,
  // Require a click on the native YouTube player for the initial playback:
  youTubeClickToPlay: true
}

Vimeo options

Options for Vimeo videos:

var vimeoOptions = {
  // The list object property (or data attribute) with the Vimeo video id:
  vimeoVideoIdProperty: 'vimeo',
  // The URL for the Vimeo video player, can be extended with custom parameters:
  // https://developer.vimeo.com/player/embedding
  vimeoPlayerUrl:
    'https://player.vimeo.com/video/VIDEO_ID?api=1&player_id=PLAYER_ID',
  // The prefix for the Vimeo video player ID:
  vimeoPlayerIdPrefix: 'vimeo-player-',
  // Require a click on the native Vimeo player for the initial playback:
  vimeoClickToPlay: true
}

Container and element options

The widget container, slidesContainer, titleElement and indicatorContainer options can be set as CSS selector or HTMLElement node, so the following are equivalent:

var options = {
  container: '#blueimp-gallery'
}
var options = {
  container: document.getElementById('blueimp-gallery')
}

CSS selectors are passed as argument to querySelectorAll, which is supported by IE8+ and all modern web browsers and queried with getElementById or getElementsByTagName in older browsers.

If the helper script is replaced with jQuery, the container and element options can be any valid jQuery selector.

Property options

The options ending with "Property" define how the properties of each link element are accessed.
For example, the urlProperty is by default set to href. This allows to define link elements with href or data-href attributes:

<div id="links">
  <a href="images/banana.jpg">Banana</a>
  <a data-href="images/apple.jpg">Apple</a>
</div>

If the links are provided as JavaScript array, it is also possible to define nested property names, by using the native JavaScript accessor syntax for the property string:

blueimp.Gallery(
  [
    {
      data: { urls: ['https://example.org/images/banana.jpg'] }
    },
    {
      data: { urls: ['https://example.org/images/apple.jpg'] }
    }
  ],
  {
    urlProperty: 'data.urls[0]'
  }
)

API

Initialization

The blueimp Gallery can be initialized by simply calling it as a function with an array of links as first argument and an optional options object as second argument:

var gallery = blueimp.Gallery(links, options)

The links array can be a list of URL strings or a list of objects with URL properties:

var gallery = blueimp.Gallery([
  'https://example.org/images/banana.jpg',
  'https://example.org/images/apple.jpg',
  'https://example.org/images/orange.jpg'
])
var gallery = blueimp.Gallery([
  {
    title: 'Banana',
    type: 'image/jpeg',
    href: 'https://example.org/images/banana.jpg',
    thumbnail: 'https://example.org/thumbnails/banana.jpg'
  },
  {
    title: 'Apple',
    type: 'image/jpeg',
    href: 'https://example.org/images/apple.jpg',
    thumbnail: 'https://example.org/thumbnails/apple.jpg'
  }
])

The URL property name defined by each list object can be configured via the urlProperty option. By default, it is set to href, which allows to pass a list of HTML link elements as first argument.

For images, the thumbnail property defines the URL of the image thumbnail, which is used for the indicator navigation displayed at the bottom of the Gallery, if the controls are visible.

The object returned by executing the Gallery function (the gallery variable in the example code above) is a new instance of the Gallery and allows to access the public API methods provided by the Gallery.
The Gallery initialization function returns false if the given list was empty, the Gallery widget is missing, or the browser doesn't pass the functionality test.

API methods

The Gallery object returned by executing the Gallery function provides the following public API methods:

// Return the current slide index position:
var pos = gallery.getIndex()

// Return the total number of slides:
var count = gallery.getNumber()

// Move to the previous slide:
gallery.prev()

// Move to the next slide:
gallery.next()

// Move to a slide index with the (optional) duration in milliseconds:
gallery.slide(index, duration)

// Start an automatic slideshow with the (optional) interval in milliseconds:
gallery.play(interval)

// Stop the automatic slideshow:
gallery.pause()

// Add additional slides after Gallery initialization:
gallery.add(list)

// Close and deinitialize the Gallery:
gallery.close()

Videos

HTML5 video player

The Gallery can be initialized with a list of videos instead of images, or a combination of both:

blueimp.Gallery([
  {
    title: 'Fruits',
    type: 'video/mp4',
    href: 'https://example.org/videos/fruits.mp4',
    poster: 'https://example.org/images/fruits.jpg'
  },
  {
    title: 'Banana',
    type: 'image/jpeg',
    href: 'https://example.org/images/banana.jpg',
    thumbnail: 'https://example.org/thumbnails/banana.jpg'
  }
])

The Gallery uses the type property to determine the content type of the object to display.
If the type property is empty or doesn't exist, the default type image is assumed.
Objects with a video type will be displayed in a HTML5 video element if the browser supports the video content type.

For videos, the poster property defines the URL of the poster image to display, before the video is started.

Video controls

To start video playback, you can either click on the video play icon or on the video slide itself.
Starting the video playback enables the native HTML5 video controls.

To toggle the Gallery controls (previous slide, next slide, etc.) instead of starting video playback on click of a video slide, add the toggle class to the video cover element using the videoCoverClass Gallery option:

blueimp.Gallery(
  [
    {
      title: 'Fruits',
      type: 'video/mp4',
      href: 'https://example.org/videos/fruits.mp4',
      poster: 'https://example.org/images/fruits.jpg'
    }
  ],
  {
    videoCoverClass: 'video-cover toggle'
  }
)

Video preloading

You can set the preload property of a Gallery video object to a valid value defined by the HTML5 video preload attribute:

  • none: Indicates that the video should not be preloaded.
  • metadata: Indicates that only video metadata (e.g. length) is fetched.
  • auto: Indicates that the whole video file can be preloaded.
blueimp.Gallery([
  {
    title: 'Fruits',
    type: 'video/mp4',
    href: 'https://example.org/videos/fruits.mp4',
    preload: 'auto'
  }
])

By default, preload is set to none to save on network bandwidth consumption.

Fullscreen video

By default, videos are displayed with the HTML5 video playsinline attribute set, which indicates that the video is to be played inline.
To disable this behavior, you can set the Gallery option videoPlaysInline to false:

blueimp.Gallery(
  [
    {
      title: 'Fruits',
      type: 'video/mp4',
      href: 'https://example.org/videos/fruits.mp4',
      poster: 'https://example.org/images/fruits.jpg'
    }
  ],
  {
    videoPlaysInline: false
  }
)

Please note that this attribute only has an effect on some mobile browsers, e.g. Safari on iOS 10 and later.
However, all browsers provide video controls to switch between fullscreen and inline mode on user request.

Multiple video sources

To provide multiple video formats, the sources property of a list object can be set to an array of objects with type and src properties for each video source. The first video format in the list that the browser can play will be displayed:

blueimp.Gallery([
  {
    title: 'Fruits',
    type: 'video',
    sources: [
      {
        type: 'video/mp4',
        src: 'https://example.org/videos/fruits.mp4'
      },
      {
        type: 'video/ogg',
        src: 'https://example.org/videos/fruits.ogv'
      }
    ],
    poster: 'https://example.org/images/fruits.jpg'
  }
])

It is also possible to define the video sources as data-sources attribute as a JSON string listing the sources array:

<div id="links">
  <a
    title="Fruits"
    type="video/mp4"
    href="https://example.org/videos/fruits.mp4"
    data-sources='[
      {
        "type": "video/mp4",
        "src": "videos/fruits.mp4"
      },
      {
        "type": "video/ogg",
        "src": "videos/fruits.ogv"
      }
    ]'
    data-poster="https://example.org/images/fruits.jpg"
    >Fruits</a
  >
</div>

YouTube

The Gallery can display YouTube videos for Gallery items with a type of text/html and a youtube property (configurable via YouTube options) with the YouTube video-ID:

blueimp.Gallery([
  {
    title: 'A YouYube video',
    type: 'text/html',
    href: 'https://www.youtube.com/watch?v=VIDEO_ID',
    youtube: 'VIDEO_ID',
    poster: 'https://img.youtube.com/vi/VIDEO_ID/maxresdefault.jpg'
  }
])

If the href and poster properties are undefined, they are set automatically based on the video ID.

Please note that the Gallery YouTube integration requires a browser with postMessage support, which excludes IE7.

Vimeo

The Gallery can display Vimeo videos for Gallery items with a type of text/html and a vimeo property (configurable via Vimeo options) with the Vimeo video-ID:

blueimp.Gallery([
  {
    title: 'A Vimeo video',
    type: 'text/html',
    href: 'https://vimeo.com/VIDEO_ID',
    vimeo: 'VIDEO_ID',
    poster: 'https://secure-b.vimeocdn.com/ts/POSTER_ID.jpg'
  }
])

If the href property is undefined, it is set automatically based on the video ID.

Please note that the Gallery Vimeo integration requires a browser with postMessage support, which excludes IE7.

Additional Gallery elements

It is possible to add additional elements to the Gallery widget, e.g. a description label.

First, add the desired HTML element to the Gallery widget:

<div
  id="blueimp-gallery"
  class="blueimp-gallery"
  aria-label="image gallery"
  aria-modal="true"
  role="dialog"
>
  <div class="slides" aria-live="polite"></div>
  <h3 class="title"></h3>
  <!-- The placeholder for the description label: -->
  <p class="description"></p>
  <a
    class="prev"
    aria-controls="blueimp-gallery"
    aria-label="previous slide"
    aria-keyshortcuts="ArrowLeft"
  ></a>
  <a
    class="next"
    aria-controls="blueimp-gallery"
    aria-label="next slide"
    aria-keyshortcuts="ArrowRight"
  ></a>
  <a
    class="close"
    aria-controls="blueimp-gallery"
    aria-label="close"
    aria-keyshortcuts="Escape"
  ></a>
  <a
    class="play-pause"
    aria-controls="blueimp-gallery"
    aria-label="play slideshow"
    aria-keyshortcuts="Space"
    aria-pressed="false"
    role="button"
  ></a>
  <ol class="indicator"></ol>
</div>

Next, add the desired element styles to your CSS file:

.blueimp-gallery > .description {
  position: absolute;
  top: 30px;
  left: 15px;
  color: #fff;
  display: none;
}
.blueimp-gallery-controls > .description {
  display: block;
}

Then, add the additional element information to each of your links:

<div id="links">
  <a
    href="images/banana.jpg"
    title="Banana"
    data-description="This is a banana."
    >Banana</a
  >
  <a href="images/apple.jpg" title="Apple" data-description="This is an apple."
    >Apple</a
  >
</div>

Finally, initialize the Gallery with an onslide callback option, to set the element content based on the information from the current link:

blueimp.Gallery(document.getElementById('links'), {
  onslide: function (index, slide) {
    var text = this.list[index].getAttribute('data-description'),
      node = this.container.find('.description')
    node.empty()
    if (text) {
      node[0].appendChild(document.createTextNode(text))
    }
  }
})

Additional content types

By extending the Gallery prototype with new factory methods, additional content types can be displayed. By default, blueimp Gallery provides the imageFactory and videoFactory methods for image and video content types respectively.

The Gallery uses the type property of each content object to determine which factory method to use. The type defines the Internet media type of the content object and is composed of two or more parts: A type, a subtype, and zero or more optional parameters, e.g. text/html; charset=UTF-8 for an HTML document with UTF-8 encoding.
The main type (the string in front of the slash, text in the example above) is concatenated with the string Factory to create the factory method name, e.g. textFactory.

Example HTML text factory implementation

Please note that the textFactory script has to be included after the core Gallery script, but before including the YouTube and Vimeo integration plugins, which extend the textFactory implementation to handle YouTube and Vimeo video links.

Please also note that although blueimp Gallery doesn't require jQuery, the following example uses it for convenience.

Extend the Gallery prototype with the textFactory method:

blueimp.Gallery.prototype.textFactory = function (obj, callback) {
  var $element = $('<div>').addClass('text-content').attr('title', obj.title)
  $.get(obj.href)
    .done(function (result) {
      $element.html(result)
      callback({
        type: 'load',
        target: $element[0]
      })
    })
    .fail(function () {
      callback({
        type: 'error',
        target: $element[0]
      })
    })
  return $element[0]
}

Next, add the text-content class to the Gallery CSS:

.blueimp-gallery > .slides > .slide > .text-content {
  overflow: auto;
  margin: 60px auto;
  padding: 0 60px;
  max-width: 920px;
  text-align: left;
}

With the previous changes in place, the Gallery can now handle HTML content types:

blueimp.Gallery([
  {
    title: 'Noodle soup',
    type: 'text/html',
    href: 'https://example.org/text/noodle-soup.html'
  },
  {
    title: 'Tomato salad',
    type: 'text/html',
    href: 'https://example.org/text/tomato-salad.html'
  }
])

jQuery plugin

jQuery plugin setup

The blueimp Gallery jQuery plugin registers a global click handler to open links with data-gallery attribute in the Gallery lightbox.

To use it, follow the lightbox setup guide, but replace the minified Gallery script with the jQuery plugin version and include it after including jQuery:

<script
  src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"
  integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ"
  crossorigin="anonymous"
></script>
<script src="js/jquery.blueimp-gallery.min.js"></script>

Next, add the attribute data-gallery to your Gallery links:

<div id="links">
  <a href="images/banana.jpg" title="Banana" data-gallery>
    <img src="images/thumbnails/banana.jpg" alt="Banana" />
  </a>
  <a href="images/apple.jpg" title="Apple" data-gallery>
    <img src="images/thumbnails/apple.jpg" alt="Apple" />
  </a>
  <a href="images/orange.jpg" title="Orange" data-gallery>
    <img src="images/thumbnails/orange.jpg" alt="Orange" />
  </a>
</div>

The onclick handler from the lightbox setup guide is not required and can be removed.

HTML5 data-attributes

Options for the Gallery lightbox opened via the jQuery plugin can be defined as HTML5 data-attributes on the Gallery widget container.

The jQuery plugin also introduces the additional filter option, which is applied to the Gallery links via jQuery's filter method and allows to remove duplicates from the list:

<div
  id="blueimp-gallery"
  class="blueimp-gallery"
  aria-label="image gallery"
  aria-modal="true"
  role="dialog"
  data-start-slideshow="true"
  data-filter=":even"
>
  <div class="slides" aria-live="off"></div>
  <h3 class="title"></h3>
  <a
    class="prev"
    aria-controls="blueimp-gallery"
    aria-label="previous slide"
    aria-keyshortcuts="ArrowLeft"
  ></a>
  <a
    class="next"
    aria-controls="blueimp-gallery"
    aria-label="next slide"
    aria-keyshortcuts="ArrowRight"
  ></a>
  <a
    class="close"
    aria-controls="blueimp-gallery"
    aria-label="close"
    aria-keyshortcuts="Escape"
  ></a>
  <a
    class="play-pause"
    aria-controls="blueimp-gallery"
    aria-label="play slideshow"
    aria-keyshortcuts="Space"
    aria-pressed="true"
    role="button"
  ></a>
  <ol class="indicator"></ol>
</div>

This will initialize the Gallery with the option startSlideshow set to true.
It will also filter the Gallery links so that only links with an even index number will be included.

Container ids and link grouping

If the data-gallery attribute value is a valid id string (e.g. "#blueimp-gallery"), it is used as container option.
Setting data-gallery to a non-empty string also allows to group links into different sets of Gallery images:

<div id="fruits">
  <a
    href="images/banana.jpg"
    title="Banana"
    data-gallery="#blueimp-gallery-fruits"
  >
    <img src="images/thumbnails/banana.jpg" alt="Banana" />
  </a>
  <a
    href="images/apple.jpg"
    title="Apple"
    data-gallery="#blueimp-gallery-fruits"
  >
    <img src="images/thumbnails/apple.jpg" alt="Apple" />
  </a>
</div>
<div id="vegetables">
  <a
    href="images/tomato.jpg"
    title="Tomato"
    data-gallery="#blueimp-gallery-vegetables"
  >
    <img src="images/thumbnails/tomato.jpg" alt="Tomato" />
  </a>
  <a
    href="images/onion.jpg"
    title="Onion"
    data-gallery="#blueimp-gallery-vegetables"
  >
    <img src="images/thumbnails/onion.jpg" alt="Onion" />
  </a>
</div>

This will open the links with the data-gallery attribute #blueimp-gallery-fruits in the Gallery widget with the id blueimp-gallery-fruits, and the links with the data-gallery attribute #blueimp-gallery-vegetables in the Gallery widget with the id blueimp-gallery-vegetables.

Gallery object

The gallery object is stored via jQuery data storage on the Gallery widget when the Gallery is opened and can be retrieved the following way:

var gallery = $('#blueimp-gallery').data('gallery')

This gallery object provides all methods outlined in the API methods section.

jQuery events

The jQuery plugin triggers Gallery events on the widget container, with event names equivalent to the gallery event callbacks:

$('#blueimp-gallery')
  .on('open', function (event) {
    // Gallery open event handler
  })
  .on('opened', function (event) {
    // Gallery opened event handler
  })
  .on('slide', function (event, index, slide) {
    // Gallery slide event handler
  })
  .on('slideend', function (event, index, slide) {
    // Gallery slideend event handler
  })
  .on('slidecomplete', function (event, index, slide) {
    // Gallery slidecomplete event handler
  })
  .on('close', function (event) {
    // Gallery close event handler
  })
  .on('closed', function (event) {
    // Gallery closed event handler
  })

Requirements

blueimp Gallery doesn't require any other libraries and can be used standalone without any dependencies.

You can also use the individual source files instead of the standalone minified version:

<link rel="stylesheet" href="css/blueimp-gallery.css" />
<link rel="stylesheet" href="css/blueimp-gallery-indicator.css" />
<link rel="stylesheet" href="css/blueimp-gallery-video.css" />
<!-- ... -->
<script src="js/blueimp-helper.js"></script>
<script src="js/blueimp-gallery.js"></script>
<script src="js/blueimp-gallery-fullscreen.js"></script>
<script src="js/blueimp-gallery-indicator.js"></script>
<script src="js/blueimp-gallery-video.js"></script>
<script src="js/blueimp-gallery-youtube.js"></script>
<script src="js/blueimp-gallery-vimeo.js"></script>

The helper script can be replaced by jQuery v. 1.7+.
The fullscreen, indicator, video, YouTube and Vimeo source files are optional if their functionality is not required.

The jQuery plugin requires jQuery v. 1.7+ and the basic Gallery script, while the fullscreen, indicator, video, YouTube and Vimeo source files are also optional:

<script
  src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"
  integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ"
  crossorigin="anonymous"
></script>
<script src="js/blueimp-gallery.js"></script>
<script src="js/blueimp-gallery-fullscreen.js"></script>
<script src="js/blueimp-gallery-indicator.js"></script>
<script src="js/blueimp-gallery-video.js"></script>
<script src="js/blueimp-gallery-youtube.js"></script>
<script src="js/blueimp-gallery-vimeo.js"></script>
<script src="js/jquery.blueimp-gallery.js"></script>

Please note that the jQuery plugin is an optional extension and not required for the Gallery functionality.

Browser support

blueimp Gallery has been tested with and supports the following browsers:

  • Chrome 14.0+
  • Safari 4.0+
  • Firefox 4.0+
  • Opera 10.0+
  • Mobile Safari 6.0+
  • Mobile Chrome 30.0+
  • Default Browser on Android 2.3+
  • Opera Mobile 12.0+
  • Edge 74+
  • Edge Legacy 41.0+
  • Internet Explorer 7.0+

License

Released under the MIT license.

Credits

The swipe implementation is based on code from the Swipe library.

gallery's People

Contributors

acortelyou avatar ameer1234567890 avatar blueimp avatar cschoenecker avatar edofic avatar iandmyhand avatar johndalangin avatar mariomc avatar mawaha avatar michael-greenwald avatar mnikkane avatar smallma avatar syntaxnode avatar tonystar avatar weberhofer avatar yaasha avatar zspitzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gallery's Issues

a few small problems

I've noticed some problems on this gallery I've made: http://photos.emmaisgoingtomarry.me/photos/index.htm

  • the slideshow interval is ignored, it still waits 5 seconds between photos:
    slideshowInterval: 1000
  • There's an error when sliding between photos:
    Uncaught Error: NotFoundError: DOM Exception 8
  • The scroll bars don't re-appear after closing an image unless I set:
    hidePageScrollbars: false

Am I doing something wrong? My gallery is almost how I want it!

thanks

usage within Bootstrap Thumbnails

Hello,

First up, this is more my issue "lack of knowledge" then Gallery's :)
I'm trying to use your great gallery in combination with Bootstrap Thumbnails.

This means that I have this structure:

<div id="links" class="hip-middle-box">
   <ul class="thumbnails">
      <li class="thmb_left">
        <a class="thumbnail left" href="images/projects/project/LP_penthouse_03.jpg">
<img src="images/projects/project/LP_penthouse_03.jpg">
        </a>
    </li>
    <li class="thmb_right">
        <a class="thumbnail right" href="images/projects/project/LP_penthouse_04.jpg"><img src="images/projects/project/LP_penthouse_04.jpg">
        </a>
    </li>
    <li class="thmb_left">
        <a class="thumbnail left" href="images/projects/project/LP_marmenor_002.jpg"><img src="images/projects/project/LP_marmenor_002.jpg">
    </li>
    <li class="thmb_right">
        <a class="thumbnail right " href="images/projects/project/LP_marmenor_012.jpg"><img src="images/projects/project/LP_marmenor_012.jpg">
    </li>
    <div id="blueimp-gallery" class="blueimp-gallery">
</ul>

The Gallery loads when clicking an image but "browsing" the images does not work as expected. This means. The image clicked opens in the gallery. Clicking next or previous will always load the first image. I suspect the issue is the parent setting. In my case the links (a) are two levels deep and not directly below the div with id="links".

What do I have to change to this:

<script>
    document.getElementById('links').onclick = function (event) {
        event = event || window.event;
        var target = event.target || event.srcElement,
            link = target.src ? target.parentNode : target,
            options = {index: link},
            links = this.getElementsByTagName('a');
        if (blueimp.Gallery(links, options)) {
            return false;
        }
    };
</script>

I tried

link = target.src ? target.parentNode.parentNode.parentNode

but that was not it... Do you have an idea?

Thanks in advance,

Johnny

Inline video in lightbox?

Is it possible to configure the Gallery for inline video in the lightbox? I can get it working fine in the carousel, but for some reason video in the lightbox always opens the video in a new window.

JS location

Hi,

I'm using the uploader for my extension and I noticed you moved this js files to a different folder and the uploader isn't working fully. Can you please locate the javascript files also where it was so it works both ways?

<script src="http://blueimp.github.com/JavaScript-Templates/tmpl.min.js"> <script src="http://blueimp.github.com/JavaScript-Load-Image/load-image.min.js"> <script src="http://blueimp.github.com/JavaScript-Canvas-to-Blob/canvas-to-blob.min.js"> changed to: <script src="http://blueimp.github.com/JavaScript-Templates/js/tmpl.min.js"> <script src="http://blueimp.github.com/JavaScript-Load-Image/js/load-image.min.js"> <script src="http://blueimp.github.com/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js">

Horizontal Space between Thumbnails

Hello, I hope this isn't me being stupid - but whilst the thumbnails are immediately flushed against each other vertically, a gap appears between every image to the right and to the left. Also, when I hover the mouse over the image, a line appears in the centre of this gap between the image hovered on and the image next to it... Thanks!

<!-- Bootstrap core CSS -->
<!-- Custom styles for this template -->

<link rel="stylesheet" href="<?php echo base_url().'cssim/blueimp-gallery.min.css' ?> ">
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls">
<div class="slides"></div>
<h3 class="title">Photos</h3>
<a class="prev">‹</a>
<a class="next">›</a>
<a class="close">×</a>
<a class="play-pause"></a>
<ol class="indicator"></ol>
</div>

<div id="links">
<a href="<?php echo base_url().'img/Bynglo-1-Llai.jpg'?>" title="View from Garden">
    <img height=75 width=75 src="<?php echo base_url().'img/Bynglo-1-Llai.jpg'?>" alt="View from Garden">
</a>
<a href="<?php echo base_url().'img/Bynglo-2-Llai.jpg'?>" title="Rear of Bungalow">
    <img height=75 width=75 src="<?php echo base_url().'img/Bynglo-2-Llai.jpg'?>" alt="Rear of Bungalow">
</a>
<a href="<?php echo base_url().'img/Bynglo-3-Llai.jpg'?>" title="Side View">
    <img height=75 width=75 src="<?php echo base_url().'img/Bynglo-3-Llai.jpg' ?>" alt="Side View">
</a>
<a href="<?php echo base_url().'img/Bynglo-4-Llai.jpg' ?>" title="Friendly Face">
    <img height=75 width=75 src="<?php echo base_url().'img/Bynglo-4-Llai.jpg' ?>" alt="Friendly Face">
</a>
<a href="<?php echo base_url().'img/Bynglo-5-Llai.jpg' ?>" title="Rear">
    <img height=75 width=75 src="<?php echo base_url().'img/Bynglo-5-Llai.jpg' ?>" alt="Rear">
</a>

<a href="<?php echo base_url().'img/Bynglo-6-Llai.jpg' ?>" title="Front">
    <img height=75 width=75 src="<?php echo base_url().'img/Bynglo-6-Llai.jpg' ?>" alt="Front">
</a>
<a href="<?php echo base_url().'img/Bynglo-7-Llai.jpg' ?>" title="Kids">
    <img height=75 width=75 src="<?php echo base_url().'img/Bynglo-7-Llai.jpg' ?>" alt="Kids">
</a>
<a href="<?php echo base_url().'img/Utility.jpg' ?>" title="Utility Room">
    <img height=75 width=75 src="<?php echo base_url().'img/Utility.jpg' ?>" alt="Utility Room">
</a>
<a href="<?php echo base_url().'img/Kitchen-1.jpg' ?>" title="Kitchen">
    <img height=75 width=75 src="<?php echo base_url().'img/Kitchen-1.jpg' ?>" alt="Kitchen">
</a>
<a href="<?php echo base_url().'img/Kitchen-2.jpg' ?>" title="Kitchen">
    <img height=75 width=75 src="<?php echo base_url().'img/Kitchen-2.jpg' ?>" alt="Kitchen">
</a>
<a href="<?php echo base_url().'img/Kitchen-3.jpg' ?>" title="View from Kitchen Window">
    <img height=75 width=75 src="<?php echo base_url().'img/Kitchen-3.jpg' ?>" alt="View from Kitchen Window">
</a>
<a href="<?php echo base_url().'img/Lounge.jpg' ?>" title="Lounge">
    <img height=75 width=75 src="<?php echo base_url().'img/Lounge.jpg' ?>" alt="Lounge">
</a>
<a href="<?php echo base_url().'img/Master.jpg' ?>" title="Master Bedroom">
    <img height=75 width=75 src="<?php echo base_url().'img/Master.jpg' ?>" alt="Master Bedroom">
</a>
<a href="<?php echo base_url().'img/Twin.jpg' ?>" title="Twin Bedroom">
    <img height=75 width=75 src="<?php echo base_url().'img/Twin.jpg' ?>" alt="Twin Bedroom">
</a>
<a href="<?php echo base_url().'img/Single.jpg' ?>" title="Single Bedroom">
    <img height=75 width=75 src="<?php echo base_url().'img/Single.jpg' ?>" alt="Single Bedroom">
</a>
<a href="<?php echo base_url().'img/Bathroom.jpg' ?>" title="Bathroom">
    <img height=75 width=75 src="<?php echo base_url().'img/Bathroom.jpg' ?>" alt="Bathroom">
</a>
<a href="<?php echo base_url().'img/SS.jpg' ?>" title="South Stack">
    <img height=75 width=75 src="<?php echo base_url().'img/SS.jpg' ?>" alt="South Stack">
</a>
</a>
    <a href="<?php echo base_url().'img/Parys.jpg' ?>" title="Parys Mountain">
    <img height=75 width=75 src="<?php echo base_url().'img/Parys.jpg' ?>" alt="Parys Mountain">
</a>
    <a href="<?php echo base_url().'img/Llynon.jpg' ?>" title="Llynon Mill">
    <img height=75 width=75 src="<?php echo base_url().'img/Llynon.jpg' ?>" alt="Llynon Mill">
</a>
        <a href="<?php echo base_url().'img/Cemlyn.jpg' ?>" title="Cemlyn Beach">
    <img height=75 width=75 src="<?php echo base_url().'img/Cemlyn.jpg' ?>" alt="Cemlyn Beach"> </div> <script src="<?php echo base_url().'js/blueimp-gallery.min.js' ?>"></script> <script>

document.getElementById('links').onclick = function (event) {
event = event || window.event;
var target = event.target || event.srcElement,
link = target.src ? target.parentNode : target,
options = {index: link, event: event},
links = this.getElementsByTagName('a');
blueimp.Gallery(links, options);
};
</script>

full size image download

Hi, I really like the gallery, it loads quickly and does most of what I need.

I have 3 sets of images - thumbnails, previews and originals. So far I have thumbnails loaded as the thumbnails, and previews used for quickly browsing large images. I want a way of adding a link to each image e.g 'Download Original Image', but I'm not sure how I can achieve this.

any tips?

thanks!

onclose event

How can I set an onclose event? Could you give me some examples?

Question on thumbnails.

I didn't see this in your documentation (sorry if I missed it), is there anyway to force the plugin to create thumbnails given the base image?

Inititate gallery from an outside href & without thumbnails

Is there a way to initiate the gallery from a generic button/link without the need to show thumbnails?

We have a "view gallery" button that we simply want to launch a lightbox gallery.

So what we output is below, but we need to call it still

<div id="links">
    <a href="images/banana.jpg"></a>
    <a data-href="images/apple.jpg"></a>
</div>

Multiple Galleries on a page?

Would it be possible to have multiple gallery sets on a page? I don't have a dedicated example page but you can look here to see what I mean:

http://www.techhounds.com/2013-season-photos

As you can see I currently have 3 different Picasa photo galleries, which I'm looking to replace with your gallery, set up on three different modals for the three different events. So would it be possible to set up three or more different Blueimp galleries on the same page?

Thumbnail scrolling option?

Nice plugin! I notice on your lightbox demo that if the number of thumbs exceed the width of the window they move to a second row etc. Would be a nice addition to have them scroll if the number exceeds the width of the window like this
just a thought….

Lightbox Gallery with Mixed Photos/Video and Play Icon Overlayed on Video Poster Img's

For example...

<div id="links">
  <a href="test.mp4", title="Test", data-poster="test-poster.jpg", data-type="video/mp4">
    <img src="test-poster.jpg" alt="Test" /> <!-- Shouldn't this get auto-generated from data-poster? -->
  </a>
  <a href="foo.jpg" title="Foo">
    <img src="foo-thumbnail.jpg" alt="Foo" />
  </a>
</div>

How can test-poster.jpg be auto generated from data-poster attribute? Also, how can I get the video play icon to be overlayed on top of this child thumbnail?

How to add a div beside the image when the lightbox is opened ?

Hi,

Congratulation for your job on Gallery. The feeling is really great !

I'd like to customise a little bit the view when the lightbox is displayed.

Currently the lightbox is centered.

What I'd like to do is having a div on the left part of the screen (let's say 250px large, with a height of 100%) which will contains comments and a description.

Here is an example made with firebug.

Thanks for you help !

screen shot 2013-07-31 at 11 34 44 pm

API Method to Set Options Live?

Love this plugin - one possible feature request, is it possible to set/change options live? I was thinking of something like gallery.option("slideshowInterval", 10000) so we could change the slide show interval live (or any other option)? If this capability is already there and I missed it, my apologies!

thumbnail link drive gallery display

Is it possible for the thumbnail links to drive the gallery display? i.e. click on a thumbnail, the gallery image changes to that image.

As set up per the doc, the thumbnail link opens the image in the main browser.

jQuery Version of the initializer

Is there a jQuery Version if this initializer?

<script>
document.getElementById('links').onclick = function (event) {
    event = event || window.event;
    var target = event.target || event.srcElement,
        link = target.src ? target.parentNode : target,
        options = {index: link, event: event},
        links = this.getElementsByTagName('a');
    blueimp.Gallery(links, options);
};
</script>

I have multiple id="links" and I change it to class="links" so i can initiate gallery in multiple albums in jquery how do i achieve this?

my pseudo code is

$(this).find('.links').initialize gallery 

something like that sorry im not too sure about it.

Strange lightbox behaviour with option clearSlides :false with demo page

click second thumb img
wait till loaded
close slide
click fourth thumb img.
slide will show the second slide img.

    var linksContainer = $('#links').on('click', 'a', function (event) {
        // Show the Gallery as lightbox when selecting a link,
        // starting with the selected image:
        if (blueimp.Gallery(linksContainer.find('a'), {
                index: $(this).data('index'),
                clearSlides: false,
            }))
        {
            // Prevent the default link action on
            // successful Gallery initialization:
            event.preventDefault();
        }
    });

Bower Exports

Can you also export the necessary images and stylesheets? Perhaps have a LESS version of stylesheet with a variable we could override for the path to the @imgDir? I had to clone this repo and then remove main in "package.json" to get my grunt build working properly.

Gallery not auto resizing

This is a new problem I'm experiencing after I updated to the latest version 2.5.0. This is happening on your demo page and my website as well.

First, I make the browser small, then I initiate the gallery, then I readjust the size of the browser, or maximize it in this case, and this happens:

broken

Lightbox on windows mobile

There are problems with the magnification of the images on windows mobile. In practice, the image is opened the top of the page, even if I click when I am in another location. The same problem with the scroll of the page.

Image Highlight In Firefox

In firefox only.

When I click a displayed image (to pop-up the controls, title, etc.), that image becomes highlighted as though I click-drag highlighted it.

I noticed it on the demo, so tried it on multiple machines and it still occurred.

Is there a simple solution to prevent this in Firefox?

firefoxhighlight

[Question] Problems with carousel

Hey,

I need a bit help with the carousel gallery.
I wanted to just add the gallery to the page, first It didnt work if I just add the carousel code snippet of your documentation.

<script> blueimp.Gallery( document.getElementById('links').getElementsByTagName('a'), { container: '#blueimp-gallery-carousel', carousel: true } ); </script>

I got it working with adding the lightbox script code and the carousel script code same time, but now the carousel gallery only appears if I click on the thumbnail images of the lightbox.

Could you help me with that? How I let the carousel gallery appear without a lightbox gallery?

PS.: Sorry for my bad english :/

Lightbox Links limits and style?

Is there any way to "limit" the visible lightbox links to say 30, then have a "Load More" button at the bottom that will load the next 30 lightbox images?

Also, is there a way to style the lightbox image links when using an AJAX call so that they look like Bootstrap Thumbnails? I know you can do it when you have the links set on your local server, but how would I do it when using an AJAX flickr call?

Doesn't play ogv or mp4 video in Opera or Chrome

I can't play nor ogv or mp4 video in Opera or Chrome
Got OK in server log:
IP.ADD.RESS.235 - guest [10/Sep/2013:15:04:37 +0400] "GET /2013/2013_06_15/VID_20130615_153017.mp4 HTTP/1.1" 200 77184288
No poster while the "loading image" waits for downloading whole file. Then "error image" appears.
Nor multiple sources or single one - it can't show me video.
But the same videos are shown in static HTML5 tag in my old gallery:

How to fix it?

Height of container = height image

When resizing the viewport I can see the black background at the top and bottom.

Is it possible to limit the height of the gallery container to the height of the image? Perhaps set the height based on the width/height ratio of the original image, so any change in the width would alter the height accordingly.

That would help a lot when designing fluid websites.

Youtube videos

Hey @blueimp, there is an easy way to show Youtube or Vimeo videos in the carousel? Could you guide me on how I do that?

Thanks,
Alan

Difference between jquery.blueimp-gallery.js and jquery.blueimp-gallery.min.js

There seems to be a vast size difference between the two. Minified version is significantly bigger.

When switching code to use unminified code (for debug) - there is an error:

Uncaught TypeError: Cannot read property 'Gallery' of undefined jquery.blueimp-gallery.js:24
(anonymous function) jquery.blueimp-gallery.js:24
(anonymous function) jquery.blueimp-gallery.js:27

Lightbox gallery dropback doesn't scroll with gallery

Thanks for the help with my previous question, but I'm experiencing another problem.

When I click on the lightbox thumbnail, the gallery initializes as it should. However, when I scroll up or down, the black backdrop doesn't scroll with the gallery and you can see what happens on my test page: http://www.techhounds.com/gallery-test/

I've noticed that this doesn't happen on your demo page. To see if it was a problem on my end, I literally copied and pasted your code from your demo page as a test, but without any success in solving this problem. I've tried removed my own resources and removing some html, but that didn't help either. Do you have any idea what's going on?

Edit: I just wanted to edit and say that changing removing the 'overflow' attribute of the class blueimp-gallery prevents any scrolling on my test page while it doesn't do so on your demo page.

Also, this is only happening on Chrome. I've tested IE and Firefox and it works fine. In IE and Firefox, both my page and your demo page don't scroll at all, which is correct isn't it?

blueimp-image-carousel

To populate the carousel I use the images inside a div. As stated in the guide. The images, however, remain visible on the page, even outside of the carousel. I would like to know if there is a function automattica that hides the div.

Not working without the demo.js

Hi,

The gallery doesn't seem to work when the reference to the source file demo.js is not included at the bottom of the page. When it is included, all the other listed items do work. What's going on?

Navigation Gallery

it is possible to always display the navigation arrows, from the beginning? thanks

carousel with lightbox

Hey thanks for making this plugin its really helpful and sorry for posting this here as this is not a issues but rather a How-to type question .

I want to use carousel and lightbox option too , like for example i want carousel to display all images in gallery and when user clicks on anyone of the image in carousel it should open in lightbox with full size image. How can i do this ??

Please can you help me with this

Doesn't work on Right-To-Left sites

Congrats on this new gallery! Looks really good!

One major issue is that it totally malfunctions on RTL sites.

Just go to the demo site, run $("body").css("direction","rtl") and gallery will stop working. Run $("body").css("direction","ltr") it will return to work again.

Controls not displaying properly

I've followed the set instructions & everything works almost perfectly but the gallery controls are not displaying properly. The angle brackets for the prev & next buttons are not positioned correctly.

I've looked for CSS conflicts but could not find any, I tried removing all css other than blueimp-gallery.min.css.

Could I be useing the wrong characters? < and >

My HTML & a screen shot is below.

thanks

<!DOCTYPE html>
<html>

  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet" media="screen" />
    <link rel="stylesheet" href="css/blueimp-gallery.min.css">    
    <link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
    <link rel="stylesheet" href="css/styles.css" />
    <link rel="stylesheet" href="css/sticky-footer.css" />
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="../../assets/js/html5shiv.js"></script>
      <script src="../../assets/js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>
    <div id="wrap">
      <div class="container">
        <nav class="navbar navbar-default" role="navigation">
        <!-- Brand and toggle get grouped for better mobile display -->
          <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.html"><img src="logo.png" alt="aka knits logo" class="logo"/></a>
          </div>

          <!-- Collect the nav links, forms, and other content for toggling -->
          <div class="collapse navbar-collapse navbar-ex1-collapse">
            <ul class="nav navbar-nav">
              <li><a href="index.html">home</a></li>
              <li><a href="about.html">about</a></li>
              <li class="active"><a href="gallery.html">gallery</a></li>
              <li><a href="contact.html">contact</a></li>
            </ul>

            <ul class="nav navbar-nav pull-right nav-pills">
              <!-- http://fortawesome.github.io/Font-Awesome/icons/#brand -->
              <li><a href="#"><i class="icon-envelope icon-1x"></i></a></li>
              <li><a href="#"><i class="icon-facebook icon-1x"></i></a></li>
              <li><a href="#"><i class="icon-twitter icon-1x"></i></a></li>
              <li><a href="#"><i class="icon-linkedin icon-1x"></i></a></li>
              <li><a href="#"><i class="icon-google-plus icon-1x"></i></a></li>
            </ul>
          </div><!-- /.navbar-collapse -->
        </nav>

        <!-- The Gallery as lightbox dialog, should be a child element of the document body -->
        <div id="blueimp-gallery" class="blueimp-gallery">
            <div class="slides"></div>
            <h3 class="title"></h3>
            <a class="prev"><</a>
            <a class="next">></a>
            <a class="close">x</a>
            <a class="play-pause"></a>
            <ol class="indicator"></ol>
        </div>

        <div id="links">
            <a href="img/gallery/banana.jpg" title="Banana">
                <img src="img/gallery/thumbnails/banana.jpg" alt="Banana">
            </a>
            <a href="img/gallery/apple.jpg" title="Apple">
                <img src="img/gallery/thumbnails/apple.jpg" alt="Apple">
            </a>
            <a href="img/gallery/orange.jpg" title="Orange">
                <img src="img/gallery/thumbnails/orange.jpg" alt="Orange">
            </a>
        </div>

      </div>
    </div>

    <div id="footer">
      <div class="container">
        <p class="text-muted credit">Footer goes here with a  <a href="#">Link</a> if required</p>
      </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="js/bootstrap.js"></script>
    <script src="js/blueimp-gallery.min.js"></script>
    <script>
      document.getElementById('links').onclick = function (event) {
          event = event || window.event;
          var target = event.target || event.srcElement,
              link = target.src ? target.parentNode : target,
              options = {index: link, event: event},
              links = this.getElementsByTagName('a');
          blueimp.Gallery(links, options);
      };
    </script>
  </body>
</html>

capture

iPad browser crash after image display

On an iPad with the Safari browser, after about some 15 to 20 displays of full-screen images of the "Lightbox image gallery" from the Demo site (manual swiping) the browser crashes.

Some investigation shows that the Chrome browser on the same iPad also crashes after roughly the same number of images.

Behaviour on MacBook (Chrome browse) shows memory going up by about 300 MB or so per image, see screenshot after > 100 image displays.

screen shot 2013-07-15 at 11 52 53 am

Looks like a resource issue (by the way GREAT application)

"Additional Gallery elements" adding problem (No Sample)

I am trying to add "Additional Gallery elements". I followed the instructions mentioned in "Additional Gallery elements". But, I don't see any "description" showing up.

I updated to 2.8.0 yesterday too to make sure I have latest version.

My question is "is it tested and does in work now". If it does then one "sample demo" would be very useful.

From my experiment, it doesn't work.

[ My images pops up from "light box". When I looks in the output, I just don't see the class="description"
has the description value. The title node (class="title") seem to get populated with the proper title value. ]

Thanks

Memory Management

Is it possible to only keep slides loaded within "preloadRange" ?
I've got a gallery with nearly 1000 photos, if I watch 'em all my ram memory is full.
So would it be possible to change the "onslide" method to release images not in range?

Option to leave Title on photo when controls disappear

Love this plugin. I implemented it in under 10min last night. One question: is it possible to have the caption stay visible when the controls disappear? In my implementation, the captions on some of the photos are humorous and I think people will want to have the captions visible all of the time. Great work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.