Fix extensionless image loading panic (#13005)
Remake of #12938 targeting main
This commit is contained in:
parent
cab1c5702a
commit
11afe16079
@ -91,13 +91,14 @@ impl AssetLoader for ImageLoader {
|
|||||||
settings: &'a ImageLoaderSettings,
|
settings: &'a ImageLoaderSettings,
|
||||||
load_context: &'a mut LoadContext<'_>,
|
load_context: &'a mut LoadContext<'_>,
|
||||||
) -> Result<Image, Self::Error> {
|
) -> Result<Image, Self::Error> {
|
||||||
// use the file extension for the image type
|
|
||||||
let ext = load_context.path().extension().unwrap().to_str().unwrap();
|
|
||||||
|
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
reader.read_to_end(&mut bytes).await?;
|
reader.read_to_end(&mut bytes).await?;
|
||||||
let image_type = match settings.format {
|
let image_type = match settings.format {
|
||||||
ImageFormatSetting::FromExtension => ImageType::Extension(ext),
|
ImageFormatSetting::FromExtension => {
|
||||||
|
// use the file extension for the image type
|
||||||
|
let ext = load_context.path().extension().unwrap().to_str().unwrap();
|
||||||
|
ImageType::Extension(ext)
|
||||||
|
}
|
||||||
ImageFormatSetting::Format(format) => ImageType::Format(format),
|
ImageFormatSetting::Format(format) => ImageType::Format(format),
|
||||||
};
|
};
|
||||||
Ok(Image::from_buffer(
|
Ok(Image::from_buffer(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user