Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpui: Support loading image from filesystem #6978

Merged
merged 6 commits into from
Jan 30, 2024
Merged

gpui: Support loading image from filesystem #6978

merged 6 commits into from
Jan 30, 2024

Conversation

bennetbo
Copy link
Contributor

@bennetbo bennetbo commented Jan 29, 2024

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.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 29, 2024
@bennetbo bennetbo marked this pull request as draft January 29, 2024 10:14
@maxdeviant maxdeviant changed the title GPUI - Support loading image from filesystem gpui: Support loading image from filesystem Jan 29, 2024
@bennetbo
Copy link
Contributor Author

bennetbo commented Jan 29, 2024

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

@bennetbo bennetbo marked this pull request as ready for review January 29, 2024 19:13
@mikayla-maki
Copy link
Member

This looks great! Thank you for the addition :D

@mikayla-maki mikayla-maki merged commit dd74643 into zed-industries:main Jan 30, 2024
6 checks passed
@bennetbo bennetbo deleted the img-file branch January 30, 2024 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants