Skip to main content

post_images

Overview​

A post's pictures, one row each, in the author's order. posts.image_url keeps a copy of the first picture's URL for older readers. Each picture may carry a caption (words shown under it for everyone) and a description (alternative text, read by screen readers and shown when the picture does not load). Both are optional; the author can add or change them after posting, without the post being marked edited (STU-2a, migration 20261016100000_post_image_captions.sql).

posts.image_alt exists from an early schema and is unused: one column cannot describe several pictures.

Columns​

ColumnTypeNullableDefaultDescription
iduuidNogen_random_uuid()Primary key
post_iduuidNo--Parent post, cascades on delete
image_urltextNo--Public URL of the file in the post-images bucket
positionintegerNo0Display order (0-based)
captiontextYes--Shown under the picture; 1 to 200 characters, trimmed, one line
alt_texttextYes--The picture's description (its alt); 1 to 400 characters, trimmed, one line
created_attimestamptzYesnow()Upload time

The two text columns refuse control characters and line or paragraph separators (CHECKs post_images_caption_shape and post_images_alt_text_shape).

Access​

  • Read: "View images of visible posts": a picture is readable wherever its post is (the policy reads posts under the reader's own RLS). Signed-out visitors have no access to the table.
  • Insert / delete: only the author of the post.
  • Update: only the author of the post, and only caption and alt_text: members hold a column-level UPDATE grant on those two columns alone, so image_url, position and post_id cannot change once written.

Uploads​

Every photo picked in the composer is re-encoded in the browser before upload (EXIF and GPS dropped, orientation applied); animated GIFs are posted as they are. See ADR-044.


Last updated: 2026-10-16