zed
zed copied to clipboard
gpui: Support loading image from filesystem
This PR implements support for loading and displaying images from a local file using gpui's img
element.
API Changes:
- Changed
SharedUrl
toSharedUrl::File
,SharedUrl::Network
Usage:
// load from network
img(SharedUrl::network(...)) // previously img(SharedUrl(...)
// load from filesystem
img(SharedUrl::file(...))
This will be useful when implementing markdown image support, because we need to be able to render images from the filesystem (relative/absolute path), e.g. when implementing markdown preview #5064.
I also added an example image
to the gpui crate, let me know if this is useful. Showcase:
Note: The example is fetching images from Lorem Picsum (Github Repo), which is a free resource for fetching images in a specific size. Please let me know if you're okay with using this in the example.
Thanks for the review, I cleaned up the example in the last commit. Still getting familiar with gpui 👍🏻
This looks great! Thank you for the addition :D