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

Add Image::uri() #4720

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions crates/egui/src/widgets/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,20 @@ impl<'a> Image<'a> {
}
}

/// Returns the URI of the image.
///
/// For GIFs, returns the URI without the frame number.
#[inline]
pub fn uri(&self) -> Option<&str> {
let uri = self.source.uri()?;

if let Ok((gif_uri, _index)) = decode_gif_uri(uri) {
Some(gif_uri)
} else {
Some(uri)
}
}

#[inline]
pub fn image_options(&self) -> &ImageOptions {
&self.image_options
Expand Down
Loading