Skip to content

Commit 5e5787c

Browse files
committed
chore: filter poster transformations
1 parent 269f1fb commit 5e5787c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/plugins/cloudinary/common.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,18 @@ const mergeTransformations = (initTransformation1, transformation2) => {
8383
// Video-only transformation keys invalid for static images (e.g. poster, sprite)
8484
export const VIDEO_ONLY_TRANSFORMATION_KEYS = ['streaming_profile', 'video_codec'];
8585

86+
const filterTxArray = (arr) =>
87+
arr.map((t) => omit(t, VIDEO_ONLY_TRANSFORMATION_KEYS)).filter((t) => Object.keys(t).length > 0);
88+
8689
export const omitVideoOnlyTransformations = (transformation) => {
8790
if (!transformation || typeof transformation !== 'object') return transformation;
8891
if (Array.isArray(transformation)) {
89-
return transformation.map((t) => omit(t, VIDEO_ONLY_TRANSFORMATION_KEYS)).filter((t) => Object.keys(t).length > 0);
92+
return filterTxArray(transformation);
93+
}
94+
if (Array.isArray(transformation?.transformation)) {
95+
const result = omit(transformation, VIDEO_ONLY_TRANSFORMATION_KEYS);
96+
result.transformation = filterTxArray(transformation.transformation);
97+
return result;
9098
}
9199
return omit(transformation, VIDEO_ONLY_TRANSFORMATION_KEYS);
92100
};

0 commit comments

Comments
 (0)