Add video thumbnails and playback in Assets
Video assets now show their first frame as a thumbnail in the grid instead of a generic Film icon, and the detail modal includes a video player with controls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,8 @@ const formatFileSize = (bytes) => {
|
||||
export default function AssetCard({ asset, onClick }) {
|
||||
const TypeIcon = typeIcons[asset.type] || File
|
||||
const isImage = asset.type === 'image'
|
||||
const isVideo = asset.type === 'video'
|
||||
const hasPreview = (isImage || isVideo) && asset.url
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -36,10 +38,19 @@ export default function AssetCard({ asset, onClick }) {
|
||||
e.target.nextSibling.style.display = 'flex'
|
||||
}}
|
||||
/>
|
||||
) : isVideo && asset.url ? (
|
||||
<video
|
||||
src={asset.url}
|
||||
preload="metadata"
|
||||
muted
|
||||
playsInline
|
||||
className="w-full h-full object-cover pointer-events-none"
|
||||
onLoadedData={(e) => { e.target.currentTime = 0.1 }}
|
||||
/>
|
||||
) : null}
|
||||
<div
|
||||
className={`flex flex-col items-center justify-center gap-2 ${isImage && asset.url ? 'hidden' : ''}`}
|
||||
style={{ display: isImage && asset.url ? 'none' : 'flex' }}
|
||||
className={`flex flex-col items-center justify-center gap-2 ${hasPreview ? 'hidden' : ''}`}
|
||||
style={{ display: hasPreview ? 'none' : 'flex' }}
|
||||
>
|
||||
<TypeIcon className="w-10 h-10 text-text-tertiary" />
|
||||
<span className="text-xs text-text-tertiary uppercase font-medium">
|
||||
|
||||
Reference in New Issue
Block a user