fix(theme): block submit on unfinished photo uploads; un-squeeze EXIF portraits in lightbox

Two prod bugs from the 2026-07-09 owner test:

- post-form.js: complete upload gate on create submit. The form plugin's
  guard only blocks PROCESSING/QUEUED, so a failed upload (processing-error)
  or a just-picked file (loading) submitted silently and the entry saved
  without its photo. Submit is now blocked unless every FilePond item is
  processing-complete, with a visible status message for the failed vs
  still-uploading cases. (Bundle rebuilt via make build-assets.)

- entry-journal partial: PhotoSwipe slides now link to a 2000px fit-within
  derivative and measure THAT file for data-pswp-width/height. The old
  img.width/height came from raw getimagesize() of the original, which
  ignores EXIF orientation, so stored-rotated portrait JPEGs got landscape
  slide boxes and rendered squeezed. Derivatives are re-encoded (EXIF
  stripped, orientation baked in server-side), so declared dims always match
  rendering. Also fixes the wrapper aspect-ratio pick for portrait-first
  entries. Note: Medium 'path' must be called as path() in Twig — the
  ArrayAccess 'path' item (page folder) shadows the method.

Covered by tests/ui/post/upload-gate.spec.js and lightbox-dims.spec.js in
the dev repo.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0195b3cDdMeize2Mm1FgC2aU
This commit is contained in:
2026-07-09 17:56:01 +02:00
co-authored by Claude Fable 5
parent 874645db32
commit e17a5dc972
3 changed files with 91 additions and 42 deletions
File diff suppressed because one or more lines are too long
+32
View File
@@ -235,6 +235,38 @@ function initPhotoConversion() {
}
}, true);
// Complete upload gate (BUG 2026-07-09: fast create submit lost the photo).
// The form plugin's own submit guard (filepond-handler.js) only blocks the
// PROCESSING / PROCESSING_QUEUED states. A file still being read (LOADING —
// the "too quick" click) or one whose upload FAILED (PROCESSING_ERROR)
// slips through it and the entry is saved without the photo — silently,
// because an errored thumbnail still satisfies the ≥1-photo count. Block
// submit unless every FilePond item reached PROCESSING_COMPLETE, and say
// which case blocked it.
form.addEventListener('submit', function (e) {
if (!orderPond) return;
var files = orderPond.getFiles();
if (!files.length) return; // the ≥1-photo rule is initValidation's job
var statuses = (window.FilePond && window.FilePond.FileStatus) || {};
var pending = 0;
var failed = 0;
files.forEach(function (f) {
if (f.status === statuses.PROCESSING_COMPLETE) return;
if (f.status === statuses.PROCESSING_ERROR || f.status === statuses.LOAD_ERROR) failed++;
else pending++; // LOADING, INIT, IDLE, QUEUED, PROCESSING, …
});
if (!pending && !failed) return;
e.preventDefault();
if (collapse) collapse.details.open = true; // reveal the item states
setStatus(failed
? 'A photo failed to upload — remove it (tap its ✕) and re-add it before posting.'
: 'Photos are still uploading — hang on a moment.', 'err');
var el = photoStatusEl();
if (el && typeof el.scrollIntoView === 'function') {
el.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
}, true);
// FilePond hook: reject a HEIC item, convert it to JPEG via the lazy heic-to
// chunk (KTD4), then re-add the JPEG through pond.addFile() so FilePond
// uploads and page-attaches it via its own (correct) contract.