Skip to content

🎥 Make videos programmatically with React

@remotion/studio: Refine Source Inspector image previews

Jonny Burger6a57fecce600
diff --git a/packages/studio/src/components/Timeline/TimelineAssetField.tsx b/packages/studio/src/components/Timeline/TimelineAssetField.tsx
index c53f04c6ef..bb9a2e42d2 100644
--- a/packages/studio/src/components/Timeline/TimelineAssetField.tsx
+++ b/packages/studio/src/components/Timeline/TimelineAssetField.tsx
@@ -306,11 +306,11 @@ export const TimelineAssetField: React.FC<TimelineAssetFieldProps> = ({
const linkInfo = getTimelineAssetLinkInfo(effectiveValue);
if (linkInfo !== null) {
let name: string;
- let source: string;
+ let source: string | null;
let previewSrc: string;
if (linkInfo.kind === 'local') {
name = linkInfo.assetPath.split('/').pop() ?? linkInfo.assetPath;
- source = 'Project asset';
+ source = null;
previewSrc = staticFile(linkInfo.assetPath);
} else {
previewSrc = linkInfo.href.startsWith('//')
@@ -340,7 +340,7 @@ export const TimelineAssetField: React.FC<TimelineAssetFieldProps> = ({
title={title}
type="button"
>
- <img alt="" src={previewSrc} style={thumbnail} />
+ <img alt="" draggable={false} src={previewSrc} style={thumbnail} />
</button>
<button
aria-label={`Replace ${name}`}
@@ -352,7 +352,9 @@ export const TimelineAssetField: React.FC<TimelineAssetFieldProps> = ({
type="button"
>
<span style={imageAssetName}>{name}</span>
- <span style={imageAssetSource}>{source}</span>
+ {source === null ? null : (
+ <span style={imageAssetSource}>{source}</span>
+ )}
</button>
{action}
</div>
diff --git a/packages/studio/src/test/quick-switcher-asset-search.test.tsx b/packages/studio/src/test/quick-switcher-asset-search.test.tsx
index 5f91772717..bb1101c8eb 100644
--- a/packages/studio/src/test/quick-switcher-asset-search.test.tsx
+++ b/packages/studio/src/test/quick-switcher-asset-search.test.tsx
@@ -259,6 +259,42 @@ test('an image asset field replaces a protocol-relative URL', () => {
expect(selectedModal).toBeNull();
});
+test('a local image preview has no generic source label and is not draggable', () => {
+ const fieldSchema = {
+ type: 'asset',
+ assetType: 'image',
+ default: undefined,
+ } satisfies AssetFieldSchema;
+
+ render(
+ <TimelineAssetField
+ field={{
+ key: 'imageSrc',
+ description: 'Image source',
+ typeName: 'asset',
+ rowHeight: 56,
+ fieldSchema,
+ group: 'source',
+ }}
+ propStatus={{
+ status: 'static',
+ codeValue: 'remotion-file:images/logo.png',
+ keyframeDisplayOffsetAdjustment: null,
+ }}
+ effectiveValue="remotion-file:images/logo.png"
+ onSave={() => Promise.resolve()}
+ onDragValueChange={() => undefined}
+ onDragEnd={() => undefined}
+ />,
+ );
+
+ expect(screen.getByText('logo.png')).toBeTruthy();
+ expect(screen.queryByText('Project asset')).toBeNull();
+ expect(document.querySelector('img')?.getAttribute('draggable')).toBe(
+ 'false',
+ );
+});
+
test('an image asset filter includes SVG files', () => {
const result = filterAssetsByType({
assets,