Skip to content

Commit 11afe16

Browse files
Fix extensionless image loading panic (#13005)
Remake of #12938 targeting main
1 parent cab1c57 commit 11afe16

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/bevy_render/src/texture/image_loader.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,14 @@ impl AssetLoader for ImageLoader {
9191
settings: &'a ImageLoaderSettings,
9292
load_context: &'a mut LoadContext<'_>,
9393
) -> Result<Image, Self::Error> {
94-
// use the file extension for the image type
95-
let ext = load_context.path().extension().unwrap().to_str().unwrap();
96-
9794
let mut bytes = Vec::new();
9895
reader.read_to_end(&mut bytes).await?;
9996
let image_type = match settings.format {
100-
ImageFormatSetting::FromExtension => ImageType::Extension(ext),
97+
ImageFormatSetting::FromExtension => {
98+
// use the file extension for the image type
99+
let ext = load_context.path().extension().unwrap().to_str().unwrap();
100+
ImageType::Extension(ext)
101+
}
101102
ImageFormatSetting::Format(format) => ImageType::Format(format),
102103
};
103104
Ok(Image::from_buffer(

0 commit comments

Comments
 (0)