Gallery view for query results

It would be nice to have a gallery view for queries that have images associated with them. For instance, books or films with cover/poster images, or contacts, etc.

Agreed, more views from queries would be incredibly useful.

Gallery, Kanban and calendar views.

I feel the queries in Logseq have not yet reached their full potential.

you can use custom view to render view as gallery. example:

:view (fn [result]
             (defn int-comma [n] (call-api "custom_num_with_comma" n))
             (when (seq result)
               [:div {:class "flex flex-row flex-wrap py-2"}
                (for [{:block/keys [uuid properties]} result]
                  [:span {:key uuid :class "flex flex-col items-center mr-2 mb-2 relative"}
                   [:span {:class "relative mb-1"} 
                    [:span {:class "absolute bottom-0 left-0 mb-1 ml-1"} [:a {:is "del-block" :data-uuid uuid}]] 
                    [:a {:on-click (fn [] (call-api "open_in_right_sidebar" (str uuid)))} [:img {:title (str (get properties :jak-title)) :style {:width "8rem" :height "8rem" :alt "NA"} :class (str (if (clojure.string/includes? (str (get properties :jak-avaliable)) "Stok tersedia") "" "opacity-50")) :src (str "https://" (get properties :jak-img))}]]
                    ]
                   [:span {:class (if (clojure.string/includes? (str (get properties :jak-avaliable)) "Stok tersedia") "" "text-red-600")} (str (get properties :jak-sku))]
                   [:span {:class (if (clojure.string/includes? (str (get properties :jak-avaliable)) "Stok tersedia") "" "text-red-600")} (str (int-comma (get properties :jak-price)) (if (> (get properties :jak-cart 0) 0) (str " (x" (get properties :jak-cart 0) ")") ""))]
                   ]
                  )]))

Thanks. Can you give more detailed instructions? I’m not sure how to use this…

complete query example. this query will get all block that contains image from current page. you can modify where clause to meet your requirement. if you click the image, the block that contains the image will open on sidebar

#+BEGIN_QUERY
{
 :query [:find (pull ?b [*])
         :in $ ?current
         :where
         [?p :block/name ?current]
         [?b :block/page ?p]
         [?b :block/content ?c]
         [(re-pattern "!\\[.*\\]\\(.*\\)") ?rx]
         [(re-find ?rx ?c)]
       ]
 :inputs [:current-page]
 :result-transform (fn [r] (map (fn [m] {:uuid (str (:block/uuid m)) :src (last (re-find (re-pattern "!\\[.*\\]\\(\\.\\.(.*)\\)") (:block/content m)))}) r))
 :view (fn [r] 
  (def graph-path (aget (call-api "get_current_graph") "path"))
  (log graph-path)
  [:div {:class "flex flex-row flex-wrap py-2"}
    (for [b r]
        [:span {:key (:uuid b) :class "flex flex-col items-center mr-2 mb-2 relative"}
          [:a {:on-click (fn [] (call-api "open_in_right_sidebar" (:uuid b)))} [:img {:style {:width "8rem" :height "8rem" :alt "NA"} :src (str "assets://" graph-path (:src b))}]]
        ]
    )
  ]
)
}
#+END_QUERY
4 Likes