Fix blank images in matrix box after upload#4124
Merged
Conversation
Images were showing blank in matrix boxes immediately after upload because process_image hadn't finished creating thumbnails. The browser would request the remote URL, get a 404, cache it, and the blank image persisted even after processing completed. Three layered fixes: 1. Generate thumbnails first in process_image — create 320 and thumb before larger sizes so matrix box images are available sooner 2. Return placeholder image URLs when no source is available — instead of falling through to the remote URL that will 404, serve place_holder_thumb.jpg or place_holder_320.jpg 3. Add Cache-Control: no-store to nginx image redirects — prevents browsers from caching 302 redirects to images that may not exist yet on the remote server. Also updates the Google Cloud archive rewrite pattern to match production (1[0123] range). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Bring repo nginx config in line with what's running in production: - Add IPv6 listeners - Add Certbot host check in HTTP->HTTPS redirect - Add Action Cable websocket location block - Update SSL cert path to -0001 (Certbot renewal) - Update comment wording to match production Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Addresses blank matrix-box images immediately after upload by avoiding early 404s (and cached failures) while thumbnails are still being generated/transferred.
Changes:
- Reorders thumbnail generation in
script/process_imageto produce 320px + thumb first. - Adds placeholder image URLs for
thumbnail/smallwhen no source is available yet. - Updates nginx image handling to prefer local files, otherwise redirect with
Cache-Control: no-store, plus syncs several production nginx settings.
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| script/process_image | Generates 320px + thumb earlier in the processing pipeline to reduce the window where matrix boxes request missing thumbnails. |
| app/models/image/url.rb | Returns placeholder URLs for thumbnail/small when neither “transferred” nor local-file sources exist. |
| config/etc/nginx.conf | Adds dedicated /images/... handling and no-store redirects, plus production parity updates (IPv6, Cable, SSL path, archive regex). |
| public/place_holder_thumb.jpg | New placeholder asset for thumbnail size. |
| public/place_holder_320.jpg | New placeholder asset for 320px size. |
Collaborator
Strip /images prefix in nginx redirect so image server receives the expected /<size>/<id>.<ext> path instead of /images/<size>/<id>.<ext>. Add test verifying that untransferred images return placeholder URLs for thumbnail/small sizes and fall back to remote source for other sizes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4123
Images were showing blank in matrix boxes immediately after upload. Root cause:
process_imagehadn't finished creating thumbnails, so the browser requested the remote image URL, got a 404, cached it, and the blank image persisted even after processing completed.Three layered fixes plus an nginx config sync:
1. Generate thumbnails first (
script/process_image)2. Placeholder fallback (
app/models/image/url.rb)transferred=false, no local file), return a placeholder image URL instead of the remote URL that will 404place_holder_thumb.jpgandplace_holder_320.jpgtopublic/for direct serving3. No-cache on nginx image redirects (
config/etc/nginx.conf)locationblock for image file paths withtry_filesto serve local files first@imageslocation returns 302 redirect withCache-Control: no-storeso browsers don't cache redirects to not-yet-transferred images4. Sync nginx config with production
-0001)1[0123]range)A fourth fix (option 1 from the issue) adds
Cache-Control: no-storeto 404 responses onimages.mushroomobserver.org— that change needs to be coordinated separately with the image server admin.Test plan
nginx -t)🤖 Generated with Claude Code