Good morning! I have a question on clerk's viewers. I added:
(clerk/set-viewers! [{:pred #(instance? Path %)
:fetch-fn (fn [_ path] {:nextjournal/content-type "image/jpg"
:nextjournal/value (Files/readAllBytes path)})
:render-fn (fn [blob] (v/html [:img {:src (v/url-for blob)}]))}])
so that I can use:
(fs/path "./art/sketch-01-001-0001-0558.jpg")
to display an image. But I wonder, why can't I do something like
(clerk/table
`[[1 2] [3 ~(fs/path "./art/sketch-01-001-0001-0558.jpg")]])
to have an image in one of the cells of the table?hey @meditans, if you can use the git dep of Clerk this now comes with support for images, see https://github.com/nextjournal/clerk/blob/4862243b1d725a09c98ac08a7046a315e4b4c63e/notebooks/viewers/image.clj. There’s also some breaking changes of the viewer api, the render-fn now needs to be quoted to make it more explicit that it doens’t run on the JVM, see https://github.com/nextjournal/clerk/commit/e4acb372d33e0e66f38cafc140226ca89591114e. As to putting an image inside a table this is something I also want. I’ll try it later, it might require some small tweaks to support this.
thanks! Those examples focus on images from the internet; do I still need something more for local images?
no, ImageIO/read takes all kinds of things, also java.io.Files
or InputStream
amazing! I'll try that right now 🙏
I also plan to cut a release later today