Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.58k stars 799 forks source link

Images in search results still use relative URLs when "Photonized" leading to a 400 error #33481

Open ballio2000 opened 11 months ago

ballio2000 commented 11 months ago

Impacted plugin

Search

Quick summary

Reported by user via ticket: 7109073-zd-a8c

Images do not display in the search results as expected with search term like Tropheus moorii bemba

Images in search results still use relative URLs when "Photonized" leading to a 400 error.

Additionally, we tested by searching fish, which some images do display in the search results. As they are external and have fully qualified URL.

Steps to reproduce

  1. Go to https://cichlidae.org.ua/
  2. Search Tropheus moorii bemba
  3. Search results do not display images (will report in a separate issue), exposing alt text showing Cyrillic encoding error.

When the author of site uses relative paths for images in post, WordPress renders the images properly. But Jetpack search doesn't generate the proper Photon URL. Jetpack Search should be using a fully qualified URL. (add site host name)

Example:

In search results (https://cichlidae.org.ua/?s=Tropheus%20moorii%20bemba) 3rd item "[Група Tropheus sp. "black"]: https://i1.wp.com/images/Tropheus/Tropheus_sp._Rutunga.jpg?resize=600%2C600

In post content (https://cichlidae.org.ua/tropheus-black-group/): /images/Tropheus/Tropheus_sp._Rutunga.jpg

A clear and concise description of what you expected to happen.

I expect the images to display in the search results, as the images work in the page when the result is clicked.

What actually happened

The images did not display correctly in the search results, only in the post content.

Impact

One

Available workarounds?

No but the platform is still usable

Platform (Simple and/or Atomic)

Self-hosted

Logs or notes

No response

github-actions[bot] commented 11 months ago

Support References

This comment is automatically generated. Please do not edit it.

jeherve commented 11 months ago

This appears to be a problem on the site itself. The images on the site have a fairly odd URL structure: https://cichlidae.org.ua/https:/cichlidenareal.ru/userfiles/vid/female/f-tc194.jpg

While this is something we could improve in the Search feature to better support such weird URLs, I think it may be worth asking the site owner if that's something they could fix on their end. If they use a specific plugin to manage image paths in their posts, can they update its settings?

stephdau commented 11 months ago

This appears to be a problem on the site itself. The images on the site have a fairly odd URL structure: https://cichlidae.org.ua/https:/cichlidenareal.ru/userfiles/vid/female/f-tc194.jpg

Heya. That one definitely is, but that's why we featured a simpler relative path example (/images/) where it turns into https://i1.wp.com/images/Tropheus/Tropheus_sp._Rutunga.jpg?resize=600x600, which is less programatically confusing/odd.

bluefuton commented 11 months ago

There seem to be two parts to this:

jeherve commented 11 months ago

we shouldn't try and Photonize images that are external to the user's site

Since Photon does photonize all images by default, I don't think this should change in Instant Search.

That said, fbcdn.net images indeed should not go through Photon, since that domain is among the few external domains we explicitely do not want to photonize: https://github.com/Automattic/jetpack/blob/aaeb9bca05e3e5e33c3dc74de9140fa968d4c552/projects/packages/image-cdn/src/class-image-cdn-core.php#L314-L333

danmaze commented 10 months ago

Any chance the issue reported in 7186771-zen is related?

ezgif-2-ee95576abe

Anything similarly odd about the Photon URL?

danmaze commented 10 months ago

Looks like that's a different issue. Just noticed the "has been blocked by cors policy" error in the console. Feel free to ignore previous comment.

github-actions[bot] commented 4 months ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.