zed icon indicating copy to clipboard operation
zed copied to clipboard

gpui: Support loading image from filesystem

Open bennetbo opened this issue 5 months ago • 1 comments

This PR implements support for loading and displaying images from a local file using gpui's img element.

API Changes:

  • Changed SharedUrl to SharedUrl::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: image

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.

bennetbo avatar Jan 29 '24 09:01 bennetbo

Thanks for the review, I cleaned up the example in the last commit. Still getting familiar with gpui 👍🏻

bennetbo avatar Jan 29 '24 19:01 bennetbo

This looks great! Thank you for the addition :D

mikayla-maki avatar Jan 30 '24 05:01 mikayla-maki