Skip to content

Image camo #66

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

Open
notriddle opened this issue Oct 14, 2016 · 6 comments
Open

Image camo #66

notriddle opened this issue Oct 14, 2016 · 6 comments
Labels
C-enhancement Category: This is a new feature E-medium Effort: This requires a fair amount of work P-low Low priority issues

Comments

@notriddle
Copy link
Contributor

When an image is included in a README or a doc file, docs.rs links directly to it. It should do like GitHub does and do proxying and caching for it.

@killercup
Copy link
Member

It might make sense to do a "quick" grep across all image tags currently rendered to look for some common domains. If the image is on imgur.com, it's already on a CDN. If it's a github link, it might be possible to rewrite the link to https://rawgit.com instead.

@jyn514
Copy link
Member

jyn514 commented Jun 28, 2020

This feels a little out of scope. From my understanding, the request is that given a link to an image hosted on an arbitrary domain, docs.rs should download a copy of that image and host it itself so that it doesn't break/is served from the same CDN as the rest of the content.

  1. I'm not sure what benefit this has. Most of big image hosting services will have much better CDNs than we do.
  2. It expands the scope of docs.rs enormously. Currently we host
  • pages rendered by rustdoc
  • pages generated by build.rs
  • nothing else

After this change we'd also store

  • every image any generated page links to

which means that you could potentially overload the server just by publishing a list of the million most popular images.

With that in mind, I don't think this is worth implementing.

@jyn514 jyn514 closed this as completed Jun 28, 2020
@pietroalbini
Copy link
Member

I think this is something that we should eventually do, as it improves the privacy of users visiting docs.rs. But it's pretty low priority.

@pietroalbini pietroalbini reopened this Jun 29, 2020
@Nemo157
Copy link
Member

Nemo157 commented Jun 29, 2020

We don’t need to store images long-term. If we are just proxying and can integrate well with a CDN to do the caching for us then this seems feasible.

@jyn514 jyn514 added C-enhancement Category: This is a new feature E-hard Effort: This will require a lot of work P-low Low priority issues labels Jul 27, 2020
@syphar
Copy link
Member

syphar commented Oct 24, 2023

From what I see this would involve rewriting the image-tags in the HTML, or hooking into rustdoc in how it generates the tags.

Both would be (I think) subject to a edge case where custom JS could still generate image links that point somewhere else, which we could solve with using img-src CSP.

The proxy itself could probably be a simple proxy endpoint. Caching it would be tricky, since I assume these external images are often dynamically generated, and used to inject dynamic content into the static docs.

The privacy improvement is IMO a valid reason to work on this.

@syphar syphar added E-medium Effort: This requires a fair amount of work and removed E-hard Effort: This will require a lot of work labels Oct 24, 2023
@jaskij
Copy link

jaskij commented Mar 10, 2025

Just to add one more argument for this feature: linkrot.

Be it Imgur removing old images, someone taking down their personal website, anything really. Links rot. It's a fact of the internet. And the only way for docs.rs to stop images included in the documentation from rotting is to host them together.

There's a related, open, but inactive, issue for rustdoc to include the images: rust-lang/rust#32104

For smaller images data URLs may also be an option?

P.S.

Can the title be changed to something more descriptive? I almost ignored this issue in search results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: This is a new feature E-medium Effort: This requires a fair amount of work P-low Low priority issues
Projects
None yet
Development

No branches or pull requests

7 participants