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

Images in instant answer are not loaded if "image proxy" is enables #875

Closed
catfluoride opened this issue Feb 6, 2022 · 13 comments · Fixed by #878
Closed

Images in instant answer are not loaded if "image proxy" is enables #875

catfluoride opened this issue Feb 6, 2022 · 13 comments · Fixed by #878
Labels
bug Something isn't working

Comments

@catfluoride
Copy link

SearXNG Version: 1.0.0-1669-10e6881c

Simple theme is used

How did you install SearXNG?

SearxNG was installed by "installation scripts", without Morty or Filtron.

What happened?

If "image proxy" is enabled, images searches work correctly. However, images in "Instant Answers" under the "General" category are absent and just a broken image placeholder is shown.

For instance, if I search for "Enrico Fermi" in the General category, with the Image Proxy enabled Wikipedia's image is broken.

How To Reproduce
This bug is reproducible. Just enable "Image Proxy" an settings GUI and perform the aforementioned search

Expected behavior

An image should be displayed in place of the broken image placeholder

Screenshots & Logs

Expected result:
expected

Actual result:
actual

Inspection of the page source gives the following:

<img src="/image_proxy?url=https%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FSpecial%3AFilePath%2FEnrico%2520Fermi%25201943-49.jpg%3Fwidth%3D500%26height%3D400&amp;h=dff389296b41618681172e6ca9f6a4e50b6ad32554484ff828889e64f4a419ab" title="Enrico Fermi" alt="Enrico Fermi">

Somewhat "image_proxy" is misbehaving on the home page.

@catfluoride catfluoride added the bug Something isn't working label Feb 6, 2022
@return42
Copy link
Member

return42 commented Feb 6, 2022

I can confirm that the image is not loaded:

INFO    werkzeug                      : 127.0.0.1 - - [06/Feb/2022 12:24:41] "GET /static/themes/simple/js/searxng.min.js HTTP/1.1" 304 -
DEBUG   searx.network.image_proxy     : HTTP Request: GET https://commons.wikimedia.org/wiki/Special:FilePath/Enrico%20Fermi%201943-49.jpg?width=500&height=400 "HTTP/1.1 302 Found" (text/html; charset=utf-8)
DEBUG   searx.webapp                  : image-proxy: wrong response code: 302
INFO    werkzeug                      : 127.0.0.1 - - [06/Feb/2022 12:24:41] "GET /image_proxy?url=https%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FSpecial%3AFilePath%2FEnrico%2520Fermi%25201943-49.jpg%3Fwidth%3D500%26height%3D400&h=c5affd8c6746b4d64eb63447da9f4138674fcab7dbc0a60576267cbea2232578 HTTP/1.1" 400 -

But the URL (now without image_proxy) ...

grafik

is valid: https://commons.wikimedia.org/wiki/Special:FilePath/Enrico%20Fermi%201943-49.jpg?width=500&height=400

@tiekoetter
Copy link
Member

tiekoetter commented Feb 6, 2022

I can't reproduce this.

If wikidata is enabled the image is broken.

See https://searx.tiekoetter.com/search?q=%21wikidata+enrico+fermi&language=en-US&time_range=&safesearch=0&theme=simple

@catfluoride
Copy link
Author

catfluoride commented Feb 6, 2022

I can't reproduce this.

If wikidata is enabled the image is broken.

See https://searx.tiekoetter.com/search?q=%21wikidata+enrico+fermi&language=en-US&time_range=&safesearch=0&theme=simple

Indeed, this it it. Disabling wikidata, everything works as expected on my instance.
Thank you for sharing this finding.

@tiekoetter
Copy link
Member

@return42 Does the image proxy have a size limit?

@return42
Copy link
Member

return42 commented Feb 6, 2022

@tiekoetter
Copy link
Member

I am currently working on a solution. I think I can do a PR soon.

@return42
Copy link
Member

return42 commented Feb 6, 2022

I am currently working on a solution. I think I can do a PR soon.

Thanks .. I also working on a solution ;-) .. I just stuck at the meaning of priority . and why it must be lower:

if attribute.priority < img_src_priority:
img_src = value
img_src_priority = attribute.priority


EDIT: I think image proxy should support redirects

@tiekoetter
Copy link
Member

tiekoetter commented Feb 6, 2022

EDIT: I think image proxy should support redirects

Maybe but then image proxy would do 2 redirects for every wikidata image. I don't think this would be good for performance.

@return42
Copy link
Member

return42 commented Feb 6, 2022

Maybe but then image proxy would do 2 redirects for every wikidata image. I don't think this would be good for performance.

This arguments counts .. I just think about rewrite the image URL in the wikidata engine ... needs some more analysis .. I just digging :)

@return42
Copy link
Member

return42 commented Feb 6, 2022

OK, if I'm not wrong all images from commons.wikimedia.org are redirected to upload.wikimedia.org .. may be it is better we do not use images from commons.wikimedia.org in the info box.

Another issue seems the lower priority condition in

if attribute.priority < img_src_priority:
img_src = value
img_src_priority = attribute.priority

@tiekoetter
Copy link
Member

@return42
tiekoetter@4c8a6cd
This should temporarily fix wikidata until a better solution can be found.

@return42
Copy link
Member

return42 commented Feb 6, 2022

@tiekoetter: I cloned your branch .. wow, very cool ..

img_src_name_md5[0] + "/" + img_src_name_md5[0:2]

from where did you know it? I have never thought that it is the prefix of md5 digest.

Do you like to send a PR .. in the PR we can do some polish, but the md5 digest is the solution I think.

@tiekoetter
Copy link
Member

from where did you know it? I have never thought that it is the prefix of md5 digest.

https://stackoverflow.com/questions/33689980/get-thumbnail-image-from-wikimedia-commons

I will send the PR now.

return42 added a commit to return42/searxng that referenced this issue Feb 7, 2022
Openstreatmap images are now loaded from uploads.wikimedia.org instead of
commons.wikimedia.org to prevent redirects.

With `image_proxy` enabled images from commons.wikimedia.org cant be loaded
since they are redirected.  We already discussed this issue [875] and
@tiekoetter fixed this issue in PR [878].

Related-to:
- [875] searxng#875
- [878] searxng#878
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
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.

3 participants