-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gpui: Improve img element to support load from Assets (#15482)
Release Notes: - N/A Currently, the `img` element provided by GPUI only supports FilePath or URL, but in actual applications we need to let `img` load an image embedded in Assets. The `svg` element can currently support this, but `img` cannot. For example: We have such an Assets directory: ``` assets |- icons |- images |--- foo.png ``` ```rs // If give a path, considered an Asset img("images/foo.png"); // If give a URI, considered a Remote image img("https://foo.bar/images/foo.png"); // If give a PathBuf, considered a Local file img(PathBuf::from("path/to/foo.png")); ``` ## Example test ``` cargo run -p gpui --example image ``` <img width="827" alt="image" src="https://github.com/user-attachments/assets/e45dcf7f-4626-4fb0-aca9-9b6e1045a952"> --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
- Loading branch information
1 parent
99bc90a
commit 1982a5a
Showing
3 changed files
with
118 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters