emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.53k stars 1.61k forks source link

Fix: How to check the image extension from Uri. #5344

Open rustbasic opened 3 weeks ago

rustbasic commented 3 weeks ago

Fix: How to check the image extension from Uri.

It addresses most of what was discussed in #5341, but I'm not sure if it addresses everything.

github-actions[bot] commented 3 weeks ago

Preview available at https://egui-pr-preview.github.io/pr/5344-patch145 Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

xangelix commented 2 weeks ago

Thank you for the PR to resolve an issue I introduced and apologies that my previous changes have caused issues for you, though I have concerns that this PR would still fail in some web URI scenarios.

Also, if this were to be the direction we go, you'd almost certainly want to do something like this to avoid having to keep extensions in sync with the image crate manually :)

    ImageFormat::all()
        .filter(ImageFormat::reading_enabled)
        .flat_map(ImageFormat::extensions_str)
        .any(|format_ext| uri.contains(*format_ext))
rustbasic commented 2 weeks ago

Thank you for the PR to resolve an issue I introduced and apologies that my previous changes have caused issues for you, though I have concerns that this PR would still fail in some web URI scenarios.

Also, if this were to be the direction we go, you'd almost certainly want to do something like this to avoid having to keep extensions in sync with the image crate manually :)

    ImageFormat::all()
        .filter(ImageFormat::reading_enabled)
        .flat_map(ImageFormat::extensions_str)
        .any(|format_ext| uri.contains(*format_ext))

I have modified this PR as you said. If you want to make a PR, I will close this PR once you submit it.