[8271] Extend the video player in the Form Engine and the preview dialog to play .avi and .mov#4814
[8271] Extend the video player in the Form Engine and the preview dialog to play .avi and .mov#4814jvega190 wants to merge 1 commit intocraftercms:developfrom
Conversation
…eviewing avi videos (not supported)
WalkthroughThe PR expands media type support by updating MIME type filters and detection logic across preview-related components. It adds support for QuickTime video (.mov) and Windows AVI video (.avi) formats, along with a blacklist mechanism in media content detection. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
ui/app/src/components/PathNavigator/utils.ts (1)
46-48: Optional: prefer inclusive naming for the blacklist constant.
blackListMediaTypes→blocklistMediaTypesordenylistMediaTypesaligns with modern inclusive language conventions.♻️ Proposed rename
-const blackListMediaTypes = [ +const blocklistMediaTypes = [ 'video/x-msvideo' // .avi files are not supported by browsers and the video player can't play them. ]; export function isMediaContent(mimeType: string) { return ( (/^image\//.test(mimeType) || /^video\//.test(mimeType) || /^audio\//.test(mimeType)) && - !blackListMediaTypes.includes(mimeType) + !blocklistMediaTypes.includes(mimeType) ); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ui/app/src/components/PathNavigator/utils.ts` around lines 46 - 48, Rename the constant blackListMediaTypes to an inclusive name (e.g., blocklistMediaTypes or denylistMediaTypes) and update all references to it across this module; specifically rename the symbol blackListMediaTypes in utils.ts, update any imports/exports or usages (functions that read or iterate this array), and adjust any type annotations or tests that reference the old name so everything compiles and passes.ui/app/src/components/PreviewSearchPanel/PreviewSearchPanel.tsx (1)
109-118: Optional: extract a shared MIME type constant to eliminate duplication betweenPreviewSearchPanelandassetsPanelInitialState.
mimeTypeshere andassetsPanelInitialState['mime-type']inpreview.tsare near-identical lists (differing only byvideo/x-msvideo). Keeping them in sync manually is a maintenance burden — adding a new format in the future will require two edits.♻️ Proposed refactor — extract to a shared constant
In a shared location (e.g.,
utils/media.ts):+export const previewableMediaMimeTypes = [ + 'image/png', + 'image/jpeg', + 'image/gif', + 'video/mp4', + 'image/svg+xml', + 'image/webp', + 'video/quicktime' +];In
PreviewSearchPanel.tsx:-const mimeTypes = [ - 'image/png', - 'image/jpeg', - 'image/gif', - 'video/mp4', - 'image/svg+xml', - 'image/webp', - 'video/quicktime', - 'video/x-msvideo' -]; +import { previewableMediaMimeTypes } from '../../utils/media'; +const mimeTypes = [...previewableMediaMimeTypes, 'video/x-msvideo'];In
preview.tsassetsPanelInitialState:-'mime-type': [ - 'image/png', - 'image/jpeg', - 'image/gif', - 'video/mp4', - 'image/svg+xml', - 'image/webp', - 'video/quicktime' -] +'mime-type': previewableMediaMimeTypes🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ui/app/src/components/PreviewSearchPanel/PreviewSearchPanel.tsx` around lines 109 - 118, Extract the duplicated MIME list into a single exported constant (e.g., MEDIA_MIME_TYPES) and replace the local mimeTypes array in PreviewSearchPanel (symbol mimeTypes) and the 'mime-type' entry in assetsPanelInitialState (symbol assetsPanelInitialState) to import and reference that constant; ensure the shared constant includes all needed types (add 'video/x-msvideo' if required) and update imports where those symbols are used so both modules reference the same source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ui/app/src/components/PathNavigator/utils.ts`:
- Around line 46-48: Rename the constant blackListMediaTypes to an inclusive
name (e.g., blocklistMediaTypes or denylistMediaTypes) and update all references
to it across this module; specifically rename the symbol blackListMediaTypes in
utils.ts, update any imports/exports or usages (functions that read or iterate
this array), and adjust any type annotations or tests that reference the old
name so everything compiles and passes.
In `@ui/app/src/components/PreviewSearchPanel/PreviewSearchPanel.tsx`:
- Around line 109-118: Extract the duplicated MIME list into a single exported
constant (e.g., MEDIA_MIME_TYPES) and replace the local mimeTypes array in
PreviewSearchPanel (symbol mimeTypes) and the 'mime-type' entry in
assetsPanelInitialState (symbol assetsPanelInitialState) to import and reference
that constant; ensure the shared constant includes all needed types (add
'video/x-msvideo' if required) and update imports where those symbols are used
so both modules reference the same source of truth.
craftercms/craftercms#8271
Summary by CodeRabbit