Skip to content

substituting /static/images for /images in all urls -fixes 12208#12352

Merged
RayBB merged 4 commits into
internetarchive:masterfrom
jack-wines:jack/fix-static-images
Apr 25, 2026
Merged

substituting /static/images for /images in all urls -fixes 12208#12352
RayBB merged 4 commits into
internetarchive:masterfrom
jack-wines:jack/fix-static-images

Conversation

@jack-wines

Copy link
Copy Markdown
Contributor

Closes #12208

refactor, the ui and tests no longer call /images, only /static/images

Technical

Different environments route /images slightly differently, some redirect, others substitute entirely. The original bug was an image only 404ing in the testing environment.

/images remains in the ngnix config, on the off chance that I missed a couple

Testing

deploy to testing environment, check nothings hits /images, and nothing hitting /static fails

Screenshot

Stakeholders

@RayBB

@mekarpeles

Copy link
Copy Markdown
Member

Thank you for your contribution, @jack-wines — and welcome to Open Library!

🤖 Copilot has been assigned for an initial review.

@RayBB is assigned to this PR and currently has:

  • 2 open PR(s) of equal or higher priority to review first
PR triage checklist (maintainers / Pam)
  • PR description — not empty; explains what the change does and how to verify it
  • References an issue — PR body contains a #NNN reference
    • Linked issue is triaged — has a Priority: * label (not just Needs: Triage)
    • Linked issue is assigned — has at least one assignee
  • Commit history clean — no WIP/fixup/conflict noise; commit messages are meaningful
  • CI passing — no failing check-runs
  • Test cases present — if the change touches substantive logic, test coverage exists or is explained
  • Proof of testing — PR body includes a description of what was tested, a screenshot, or a video

Note

This comment was automatically generated by Pam, Open Library's Project AI Manager, on behalf of @mekarpeles. Pam is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors Open Library UI, templates, and tests to consistently reference static image assets via /static/images instead of /images, addressing environment-specific routing differences that caused image 404s in testing (Closes #12208).

Changes:

  • Updated many templates/macros and JS fallbacks to use /static/images/... for icons, loaders, and placeholder covers.
  • Updated test fixtures/expectations to match the new /static/images/... URLs.
  • Updated static assets referencing (e.g., manifest.json, status-500.html) to point at /static/images/....

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/js/sample-html/lists-test-data.js Updates default cover URL in sample markup data to /static/images.
tests/unit/js/lists.test.js Updates unit test cover URL expectations to /static/images.
static/status-500.html Updates 500 error page logo to /static/images.
static/manifest.json Updates PWA screenshot URLs to /static/images.
static/css/components/generic-dropper.css Updates dropper icon URL (but currently reintroduces /images in one rule).
openlibrary/templates/type/list/embed.html Updates logo and default cover URL to /static/images.
openlibrary/templates/type/author/view.html Updates loader gif URL to /static/images.
openlibrary/templates/type/author/edit.html Updates help icon URL to /static/images.
openlibrary/templates/search/sort_options.html Updates sort icon URL to /static/images.
openlibrary/templates/lists/snippet.html Updates default cover URL to /static/images.
openlibrary/templates/lists/showcase.html Updates default cover URL to /static/images.
openlibrary/templates/lists/preview.html Updates default cover URL to /static/images.
openlibrary/templates/lists/list_follow.html Updates default cover URL to /static/images.
openlibrary/templates/lists/home.html Updates default cover URL to /static/images.
openlibrary/templates/covers/book_cover.html Updates placeholder book cover + srcset URLs to /static/images.
openlibrary/templates/covers/book_cover_small.html Updates small placeholder cover URLs to /static/images.
openlibrary/templates/covers/author_photo.html Updates placeholder author image URL to /static/images.
openlibrary/templates/books/edition-sort.html Updates fallback cover URL to /static/images.
openlibrary/templates/books/edit/edition.html Updates dimensions image URL to /static/images.
openlibrary/templates/account/not_verified.html Updates alert background icon URL to /static/images.
openlibrary/plugins/upstream/tests/test_addbook.py Updates expected cover_url to /static/images.
openlibrary/plugins/upstream/code.py Changes dev redirect handler route (currently results in incorrect redirect target).
openlibrary/plugins/upstream/addbook.py Updates make_work fallback cover_url to /static/images.
openlibrary/plugins/openlibrary/lists.py Updates list API cover_url fallback to /static/images.
openlibrary/plugins/openlibrary/js/my-books/MyBooksDropper/ReadingLists.js Updates default cover URL constant to /static/images.
openlibrary/plugins/openlibrary/js/lists/ShowcaseItem.js Updates default cover URL constant to /static/images.
openlibrary/plugins/openlibrary/js/covers.js Updates author placeholder image URL to /static/images.
openlibrary/macros/SearchResultsWork.html Updates default cover URL to /static/images.
openlibrary/macros/LoadingIndicator.html Updates loader gif URL to /static/images.
openlibrary/macros/FulltextSearchSuggestionItem.html Updates default cover URL to /static/images.
openlibrary/macros/CoverImage.html Updates default cover URL to /static/images.

Comment thread openlibrary/plugins/upstream/code.py Outdated
Comment thread static/css/components/generic-dropper.css Outdated
@jack-wines jack-wines force-pushed the jack/fix-static-images branch from 10c506b to 97b5811 Compare April 12, 2026 16:01
@RayBB RayBB requested a review from lokesh April 13, 2026 23:43
@RayBB

RayBB commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

Put it on testing and it resolves the issue. I think this is meaningful improvement.

Tagging @lokesh just for a quick sanity check in case he has concerns.

logger = logging.getLogger('openlibrary.plugins.upstream.code')


# Note: This is done in web_nginx.conf on production ; this endpoint is

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR removes the shim for dev environments, which is a good idea, but there are quite a few image references remaining that need to have their url updated to include the /static/ folder or they will break on dev.

It might appear they are still working when you test locally, but try clearing site data and trying again.

All the image urls that need fixing still are in CSS files.

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good call! I'll clear cache and take a second look.

@jack-wines

Copy link
Copy Markdown
Contributor Author

The failing test is in a file that wasn't changed. It passes locally. In the meantime there's a merge conflict with the master branch, which ran linting on the js and added semicolons where there weren't previously. I'll pull and rebase.

@github-actions github-actions Bot added the Needs: Response Issues which require feedback from lead label Apr 17, 2026
@RayBB RayBB added Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] and removed Needs: Response Issues which require feedback from lead labels Apr 17, 2026
@jack-wines jack-wines force-pushed the jack/fix-static-images branch from 574ed27 to c1711a1 Compare April 18, 2026 04:25
@github-actions github-actions Bot removed the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Apr 18, 2026
@jack-wines

Copy link
Copy Markdown
Contributor Author

woah that rebase did not work out. One minute.

@jack-wines jack-wines force-pushed the jack/fix-static-images branch from c1711a1 to 6c1ac9c Compare April 18, 2026 04:57
@jack-wines

jack-wines commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

That's better. What I did here was
a) mass replace '/images with '/static/images (js), (/images with (/static/images (css) and "/images with "/images with /static/images (js/json/python)
b) to a project search for /images and make sure everything that should be changed was changed/I didn't miss anything and
c) browse the ui in dev with cache disabled while keeping at eye on http requests to make sure nothing 404'd.

@jack-wines

Copy link
Copy Markdown
Contributor Author

To make things easier to review

grep -r "[^c]/images" | less

provides a list of all /images lines that don't match c/images (which is the last character of "static"). So if there's something I missed, it would be in that list. If you have ripgrep installed, substituting rg for grep -r ignores .git.

@github-actions github-actions Bot added the Needs: Response Issues which require feedback from lead label Apr 18, 2026

@accesslint accesslint Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 1 issue across 1 rule.

Comment thread openlibrary/templates/covers/author_photo.html

@RayBB RayBB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has been on testing for a while and looks good.

Also ran a little script to confirm all the new urls are valid on production and it worked.

Thanks for making your first contribution and I hope you can come make some more!

@RayBB RayBB merged commit 928ae51 into internetarchive:master Apr 25, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project Apr 25, 2026
@jack-wines

Copy link
Copy Markdown
Contributor Author

Yes! I'll be picking out my next victim soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Fix static images on testing

5 participants