             [:div.pswp__caption__center]]]]]
         [:div.gallery {:itemscope ""
                        :itemtype "http://schema.org/ImageGallery"}
-         (for [photo photos
-               :let [caption (format "Submission %s" (:rank photo))]]
-           [:figure {:itemprop "associatedMedia"
-                     :itemscope ""
-                     :itemtype "http://schema.org/ImageObject"}
-            [:a {:href (:src photo)
-                 :itemprop "contentUrl"
-                 :data-size (format "%sx%s" width-px width-px)}
-             [:img {:src (:thumb photo)
-                    :itemprop "thumbnail"
-                    :alt caption}]]
-            [:figcaption {:itemprop "caption description"} caption]])]]))
-    om/IDidMount
-    (did-mount [_]
-      (let [pswp-element (first (.querySelectorAll js/document ".pswp"))
-            options {:index 0 ;; start at the first slide
-                     }
-            gallery (js/PhotoSwipe. pswp-element
-                                    js/PhotoSwipeUI_Default
-                                    (clj->js (om/get-state owner :photos))
-                                    (clj->js options))]
-        (.init gallery)))))
+         (build-photo-gallery photos owner)]]))))

  [str]
  (remote/make-url (replace str #"/api/v1" "")))

(defn build-photos
  "Build photos for photoswipe from a set of form data."
  [data]
  (flatten

            [hatti.views :refer [photos-page]]
            [milia.utils.remote :as remote]))

(def data-pswp-id "data-pswp-id")
(def pswp-gallery-class "pswp")
(def width-px 400)

(defn- make-url
