Show a post's image on its card, and show it full size #172
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "blindxfish/devplacepy:PostCardPolish"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Brings post image rendering in line with the original DevPlace, where a post's image is a full-width part of the card rather than a thumbnail chip. Two things were in the way.
1. Feed and profile cards never rendered attachments at all
_attachment_display.htmliterates a context variable namedattachments, so every caller binds it before the include -_comment.htmluses{% set attachments = item.get('attachments', []) %},messages.htmluses{% with %},post.htmlandgist_detail.htmlget it from their route context,project_detail.htmlsets it fromother_attachments._post_card.htmlwas the one caller that did not. It guarded onitem.attachmentsbut then included the partial with nothing bound, so the loop ran over whateverattachmentshappened to be in the surrounding page context and the card rendered an empty<div class="attachment-gallery">. Every post with an image looked image-less on/feedand on a profile.The same defect had a second, worse face:
project_detail.htmlsetsattachmentsat template scope for the project's own files and renders devlog post cards further down the page, so a devlog post that had its own attachments would have rendered the project's files as if they belonged to the post.Fixed by binding it the way
_comment.htmlalready does, and pinned bytests/e2e/feed.py::test_feed_card_shows_the_post_image.2. A single image is now a hero, not a chip
When the gallery holds exactly one item the partial adds a
singleclass, andattachments.cssgives that item the full content column:width: 100%,max-height: 480px,object-fit: contain, and no hover scale (scaling a full-width image looks broken). That mirrors the original'sw-full object-containtreatment. A multi-item gallery keeps the existing 240x200 chips.The
singlebranch servesatt['url'], neverthumbnail_url. A thumbnail is 200px on its longest side, so stretching one to the column width is visibly blurry - that is the whole reason thesrcis a conditional rather than "thumbnail whenever one exists". Verified by screenshotting a real rendered card, not just by asserting on markup.Because the partial is shared, this lands on post cards, post detail, comments, gists, projects and chat bubbles at once.
GIFs
No change was needed - they were already correct end to end, and this PR confirms it with a test.
.gifis inALLOWED_UPLOAD_TYPES,THUMBNAIL_EXTENSIONSdeliberately excludes it so animation is never flattened into a static JPEG, bothmain.py'sINLINE_MEDIA_EXTENSIONSand the nginxmap $uri $upload_dispositionserve itinline, and both render pipelines already match.gif. An animated GIF simply took the original-file path already; it now displays at hero size like any other single image.test_animated_gif_post_serves_the_original_fileasserts the original.gifis what reaches the page.Worth knowing before merge
The hero serves the full-resolution original everywhere the partial renders, including chat bubbles and comments, which previously showed the 200px thumbnail. Images are lazy-loaded and bounded by
max_upload_size_mb, but a large phone photo in a DM now transfers on render instead of on lightbox click. The clean long-term fix is a mid-size (~1200px) derivative generated beside the thumbnail and used for heroes; that belongs in its own change since it touchesattachments.pyand needs its own tests.Tests
Four new e2e tests, plus
create_post_with_files()moved intotests/conftest.pyso the feed and post tiers share one composer-with-attachments helper:feed.py::test_feed_card_shows_the_post_image- the regression guard for the binding bugpost.py::test_single_image_post_shows_the_original_full_size- hero serves the original, not the thumbnailpost.py::test_multiple_image_post_keeps_thumbnails- multi-image galleries still use thumbnailspost.py::test_animated_gif_post_serves_the_original_fileFull suite in the project's Docker image: 3355 passed, 9 failed in 26m56s. All nine failures are the
tests/api/projects/workspace.pycontainer-manager tests, which fail withFileNotFoundError: 'docker'because that image only ships the docker CLI when built withINSTALL_DOCKER_CLI=true; they reproduce identically on a pristineHEADcheckout in the same container. Collected count matches exactly: master's 3360 plus the 4 tests added here.🤖 Generated with Claude Code
Great, but please rebase.
24a79177e8to8856c38b4dCheckout
From your project repository, check out a new branch and test the changes.