           subSelector = "#{subSelector} #{opts.itemSelector}"
 
         window.folioLightboxInstances.push(new window.FolioLightbox(subSelector))
+    else if opts.fromData
+      $items.each ->
+        window.folioLightboxInstances.push(
+          new window.FolioLightbox(selector,
+                                   false,
+                                   $(this).data('lightbox-image-data'))
+        )
     else
       window.folioLightboxInstances.push(new window.FolioLightbox(selector))
 

        history: false
        errorMsg: @pswp().data('error-msg')

      @photoSwipe = new PhotoSwipe(@pswp()[0], PhotoSwipeUI_Default, @items(), options)
      @photoSwipe.init()

  items: ->

#= require photoswipe/photoswipe-ui-default

class window.FolioLightbox
  constructor: (selector, additionalSelector = false, data = null) ->
    @selector = selector
    if additionalSelector
      @full_selector = "#{selector}, #{additionalSelector}"
    else
      @full_selector = selector
    @eventIdentifier = "folioLightbox"
    @bind(data)

  pswp: ->
    @$pswp ||= $('.pswp')
    @$pswp

  bind: (data) ->
    $(document).on "click.#{@eventIdentifier}", @full_selector, (e) =>
      e.preventDefault()
      $img = $(e.target)
