Skip to content

Commit

Permalink
Make image extension lowercase before checking if it is supported (#5501
Browse files Browse the repository at this point in the history
)

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Images with capitalized extensions do not load because the list of
extensions they are checked against is lowercase. The image extension is
now converted to lowercase before comparing
* [x ] I have followed the instructions in the PR template
  • Loading branch information
RyanBluth authored Dec 28, 2024
1 parent c37125f commit 8131b7b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/egui_extras/src/loaders/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ impl ImageCrateLoader {
}

fn is_supported_uri(uri: &str) -> bool {
let Some(ext) = Path::new(uri).extension().and_then(|ext| ext.to_str()) else {
let Some(ext) = Path::new(uri)
.extension()
.and_then(|ext| ext.to_str().map(|ext| ext.to_lowercase()))
else {
// `true` because if there's no extension, assume that we support it
return true;
};
Expand Down

0 comments on commit 8131b7b

Please sign in to comment.