# gpui: Support loading image from filesystem \(\#6978\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/dd74643993b13de285b184d6ab26cf0a16c00162)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: dd74643993b13de285b184d6ab26cf0a16c00162

Requested commit: dd74643993b13de285b184d6ab26cf0a16c00162

Commit: dd74643993b13de285b184d6ab26cf0a16c00162

Tree: 6565ed7bf119634ab74c74e64475385822d153c3

Author: Bennet Bo Fenner

Committer: GitHub

## Message

````
gpui: Support loading image from filesystem (#6978)

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:
```rust
// 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:
<img width="872" alt="image"
src="https://github.com/zed-industries/zed/assets/53836821/b4310a26-db81-44fa-9a7b-61e7d0ad4349">

**Note**: The example is fetching images from [Lorem
Picsum](https://picsum.photos) ([Github
Repo](https://github.com/DMarby/picsum-photos)), 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.
````

## Parents

- [b865db455db19e192746980aee0e2c32c286afc7](https://git.cafe/gitcafe/zed/commit/b865db455db19e192746980aee0e2c32c286afc7?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/dd74643993b13de285b184d6ab26cf0a16c00162?format=markdown)
