Reagent components for displaying images.
An <img> src can't send a bearer token, so images from an API that requires one are fetched as blobs and shown through object URLs.
Reagent components for displaying images. An <img> src can't send a bearer token, so images from an API that requires one are fetched as blobs and shown through object URLs.
(cached-image {k :key :keys [fetch html]})Renders an image that must be fetched by the caller, e.g. one served by an API that requires authentication. Renders nothing while the image is loading, or if it can't be fetched.
The object URL for each key is cached for the life of the page, so an image is fetched only once, and a failed fetch is not retried. A key must therefore always identify the same image.
Options: :key - identifies the image; it must never refer to a different image :fetch - (fn [on-success on-error]) that retrieves the image, calling on-success with a Blob or on-error with the error :html - attributes merged into the <img>, e.g. :alt and :class (default style is object-fit: cover)
Renders an image that must be fetched by the caller, e.g. one served by
an API that requires authentication. Renders nothing while the image is
loading, or if it can't be fetched.
The object URL for each key is cached for the life of the page, so an
image is fetched only once, and a failed fetch is not retried. A key must
therefore always identify the same image.
Options:
:key - identifies the image; it must never refer to a different image
:fetch - (fn [on-success on-error]) that retrieves the image, calling
on-success with a Blob or on-error with the error
:html - attributes merged into the <img>, e.g. :alt and :class
(default style is object-fit: cover)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |