diff --git a/crates/egui_extras/src/loaders/image_loader.rs b/crates/egui_extras/src/loaders/image_loader.rs index a07f2caf5b6..1a90c7c7206 100644 --- a/crates/egui_extras/src/loaders/image_loader.rs +++ b/crates/egui_extras/src/loaders/image_loader.rs @@ -18,77 +18,12 @@ impl ImageCrateLoader { pub const ID: &'static str = egui::generate_loader_id!(ImageCrateLoader); } -fn get_ext_from_image_uri(uri: &str) -> String { - if uri.trim().is_empty() { - return String::new(); - } - - let image_uri = uri.to_lowercase(); - - let auto_ext: String = if image_uri.contains(".png") { - "png".to_owned() - } else if image_uri.contains(".jpg") { - "jpg".to_owned() - } else if image_uri.contains(".jpeg") { - "jpeg".to_owned() - } else if image_uri.contains(".gif") { - "gif".to_owned() - } else if image_uri.contains(".ico") { - "ico".to_owned() - } else if image_uri.contains(".svg") { - "svg".to_owned() - } else if image_uri.contains(".webp") { - "webp".to_owned() - } else if image_uri.contains(".apng") { - "apng".to_owned() - } else if image_uri.contains(".avif") { - "avif".to_owned() - } else if image_uri.contains(".bmp") { - "bmp".to_owned() - } else if image_uri.contains(".dds") { - "dds".to_owned() - } else if image_uri.contains(".exr") { - "exr".to_owned() - } else if image_uri.contains(".ff") { - "ff".to_owned() - } else if image_uri.contains(".hdr") { - "hdr".to_owned() - } else if image_uri.contains(".pbm") { - "pbm".to_owned() - } else if image_uri.contains(".pam") { - "pam".to_owned() - } else if image_uri.contains(".ppm") { - "ppm".to_owned() - } else if image_uri.contains(".pgm") { - "pgm".to_owned() - } else if image_uri.contains(".qoi") { - "qoi".to_owned() - } else if image_uri.contains(".tif") { - "tif".to_owned() - } else if image_uri.contains(".tiff") { - "tiff".to_owned() - } else if image_uri.contains(".tga") { - "tga".to_owned() - } else { - // If the image format is unknown, it is assumed to be `png`. - "png".to_owned() - }; - - auto_ext -} - fn is_supported_uri(uri: &str) -> bool { - let ext = get_ext_from_image_uri(uri); - if ext.is_empty() { - // `true` because if there's no extension, assume that we support it - return true; - } - // Uses only the enabled image crate features ImageFormat::all() .filter(ImageFormat::reading_enabled) .flat_map(ImageFormat::extensions_str) - .any(|format_ext| ext == *format_ext) + .any(|format_ext| uri.contains(*format_ext)) } fn is_unsupported_mime(mime: &str) -> bool {