Skip to content

Commit f1d9ebd

Browse files
authored
Feature/duration to condition video
1 parent 8d80263 commit f1d9ebd

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

lib-es5/utils/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ var PREDEFINED_VARS = {
128128
"aspectRatio": "ar",
129129
"current_page": "cp",
130130
"currentPage": "cp",
131+
"duration": "du",
131132
"face_count": "fc",
132133
"faceCount": "fc",
133134
"height": "h",
@@ -137,6 +138,8 @@ var PREDEFINED_VARS = {
137138
"initialAspectRatio": "iar",
138139
"initialHeight": "ih",
139140
"initialWidth": "iw",
141+
"initial_duration": "idu",
142+
"initialDuration": "idu",
140143
"page_count": "pc",
141144
"page_x": "px",
142145
"page_y": "py",

lib/utils/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const PREDEFINED_VARS = {
120120
"aspectRatio": "ar",
121121
"current_page": "cp",
122122
"currentPage": "cp",
123+
"duration": "du",
123124
"face_count": "fc",
124125
"faceCount": "fc",
125126
"height": "h",
@@ -129,6 +130,8 @@ const PREDEFINED_VARS = {
129130
"initialAspectRatio": "iar",
130131
"initialHeight": "ih",
131132
"initialWidth": "iw",
133+
"initial_duration": "idu",
134+
"initialDuration": "idu",
132135
"page_count": "pc",
133136
"page_x": "px",
134137
"page_y": "py",

test/utils_spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,28 @@ describe("utils", function () {
843843
});
844844
expect(url).to.eql("http://res.cloudinary.com/test123/image/upload/if_w_lt_200,c_fill,h_120,w_80/sample");
845845
});
846+
describe('conditional duration video', function () {
847+
it("should include conditional transformation", function () {
848+
var url = utils.url("test", {
849+
resource_type: 'video',
850+
if: "duration > 30",
851+
width: 100,
852+
});
853+
expect(url).to.eql("http://res.cloudinary.com/test123/video/upload/if_du_gt_30,w_100/test");
854+
url = utils.url("test", {
855+
resource_type: 'video',
856+
if: "initialDuration > 30",
857+
width: 100,
858+
});
859+
expect(url).to.eql("http://res.cloudinary.com/test123/video/upload/if_idu_gt_30,w_100/test");
860+
url = utils.url("test", {
861+
resource_type: 'video',
862+
if: "initial_duration > 30",
863+
width: 100,
864+
});
865+
expect(url).to.eql("http://res.cloudinary.com/test123/video/upload/if_idu_gt_30,w_100/test");
866+
});
867+
});
846868
it("should allow multiple conditions when chaining transformations ", function () {
847869
var url = utils.url("sample", {
848870
transformation: [

0 commit comments

Comments
 (0)