Add `Image::uri()` (#4720)
`uri()` for image The advantages of this are : 1. No need for `ctx()` and `source()` 2. Displays `name.gif#0` as `name.gif`
This commit is contained in:
parent
9a4c46289e
commit
ad597a8491
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue