Repository navigation
Fix video dimension extraction and Uploaded row truncation in media details - #3685
Conversation
…etails EmDash-Run: 5c4a0857-fb1b-43b5-a8ba-c9c4c90cdd02
🦋 Changeset detectedLatest commit: 9a09b0f The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://bot-fix-3682.try.emdashcms.com, https://bot-fix-3682-emdash-playground.emdash-cms.workers.dev (commit 9a09b0f)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-test
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-loader
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
This PR correctly identifies that video uploads lack dimension reporting and that the details panel truncates the Uploaded date when no Dimensions row exists. Using a <video> element to read videoWidth/videoHeight client-side and sending the dimensions through both the direct-upload form and the signed-URL confirmation payload is consistent with how image dimensions already flow, and the server routes already accept and prefer client-provided dimensions.
I checked:
getVideoDimensionsmirrors the existinggetImageDimensionspattern (object URL, abort cleanup, resolve-null on error).- Server-side
enrichImageMetadataskips non-image types, so the client-provided video dimensions are preserved in bothPOST /mediaandPOST /media/:id/confirm. - No new user-facing strings (i18n workflow not needed) and no new public admin API surface (
getVideoDimensionsis not re-exported fromlib/api/index.ts). - The changeset is clear and scoped to
@emdash-cms/admin.
I found two issues to address before merge:
- The details-panel grid fix only pins
gridColumnStart. When dimensions are absent, CSS Grid auto-placement putsFormatin row 1 column 2 and dropsUploadedto row 2 column 1, soFormatvisually appears beforeUploaded. The fix should also pingridRowStart: 2onUploadedandFormatso they stay on the same secondary row. - The regression test for that layout only asserts
gridColumnStart, so it passes regardless of the reordering. It should assertgridRowStartas well.
I also noted two comments that merely restate the next line; those can be removed while the code is being touched.
Findings
-
[needs fixing]
packages/admin/src/components/MediaDetailPanel.tsx:1321-1351When dimensions are absent, the grid now pins
Uploadedto column 1 but not to row 2. CSS Grid auto-placement will putFormatin row 1 column 2 and dropUploadedto row 2 column 1, soFormatvisually jumps aboveUploaded.The stated fix is to keep
Uploadedin the wider column; it should stay on the same row asFormat.{!isProviderAsset && ( <div className="flex min-w-0 items-start gap-2 text-sm" style={{ gridColumnStart: 1, gridRowStart: 2 }} ><div className="flex min-w-0 items-start gap-2 text-sm" style={{ gridColumnStart: 2, gridRowStart: 2 }} > -
[needs fixing]
packages/admin/tests/components/MediaDetailPanel.test.tsx:319-330The regression test only checks
gridColumnStart, so it cannot fail ifFormatmoves into row 1 whileUploadeddrops to row 2. A layout regression test should also assert the row placement.await expect.element(screen.getByText("Uploaded:")).toBeInTheDocument(); expect(getComputedStyle(factByLabel("Size:")).gridColumnStart).toBe("1"); expect(getComputedStyle(factByLabel("Uploaded:")).gridColumnStart).toBe("1"); expect(getComputedStyle(factByLabel("Uploaded:")).gridRowStart).toBe("2"); expect(getComputedStyle(factByLabel("Format:")).gridColumnStart).toBe("2"); expect(getComputedStyle(factByLabel("Format:")).gridRowStart).toBe("2"); -
[suggestion]
packages/admin/src/lib/api/media.ts:520-573These two comments only restate the following line. Since the code is being touched here, delete the comments instead of updating them.
async function uploadMediaDirect(file: File, opts?: UploadMediaOptions): Promise<LocalMediaItem> { const dimensions = await getMediaDimensions(file, opts);await uploadToSignedUrl(file, uploadInfo, opts); const dimensions = await getMediaDimensions(file, opts);
What does this PR do?
Closes #3682.
.mp4,.webm,.mov) client-side and sends them in both upload paths.A patch changeset for
@emdash-cms/adminis included.Closes #3682.
A candidate change the reporter confirmed against their own site via the preview build:
Opened automatically by emdashbot as a draft. A maintainer must review before merge.
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
Screenshots / test output