Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Not all image URLs are supported #253

Open
Anush008 opened this issue Oct 31, 2024 · 2 comments · May be fixed by #255
Open

Bug: Not all image URLs are supported #253

Anush008 opened this issue Oct 31, 2024 · 2 comments · May be fixed by #255
Labels
bug Something isn't working

Comments

@Anush008
Copy link
Member

Anush008 commented Oct 31, 2024

The web UI looks for image URLs ending with jpg|jpeg|png|webp|gif|svg before displaying them on the dashboard.

So it won't work for ones like
https://cdn.discordapp.com/attachments/927784326899331092/1301524272585379932/og.png?ex=6724ca6f&is=672378ef&hm=6584c97a3a83eb4e23505bfdb0b88739c36b494deb9501c60ae9d9bcb652601e&

I think we should check if the value is a URL and image content type is returned in its HEAD response.

Related file:

function isImgUrl(string) {
let url;
try {
url = new URL(string);
} catch (_) {
return false;
}
if (url) {
return /\.(jpg|jpeg|png|webp|gif|svg)$/.test(url.pathname);
}
return false;
}

@Anush008 Anush008 changed the title Not all image URLs are supported Bug: Not all image URLs are supported Oct 31, 2024
@Anush008 Anush008 added the bug Something isn't working label Oct 31, 2024
@kartik-gupta-ij
Copy link
Contributor

Hey @Anush008,

Thanks for pointing this out! Currently, the Web UI indeed looks for image URLs containing extensions like .jpg|jpeg|png|webp|gif|svg within the string, not just at the end. This means URLs like the one you shared should be rendered fine, as long as they include one of these extensions.
Screenshot 2024-11-01 at 5 08 29 PM

Regarding the idea of checking the content type via a HEAD request to confirm it's an image – that’s a solid approach, but it might run into CORS issues with some images. If the server blocks these requests, we won’t be able to access the headers directly. Let me know if you want to explore this further, or if you have any other ideas!

@Anush008
Copy link
Member Author

Anush008 commented Nov 1, 2024

Thanks for pointing this out! Currently, the Web UI indeed looks for image URLs containing extensions like .jpg|jpeg|png|webp|gif|svg within the string, not just at the end.

Right. Got it. That would still miss URLs like https://www.bothellwa.gov/ImageRepository/Document?documentID=8024

Regarding the idea of checking the content type via a HEAD request to confirm it's an image – that’s a solid approach, but it might run into CORS issues with some images. If the server blocks these requests,

We don't have to render such images if a server blocks them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants