Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit c33194d

Browse files
committed
Support YoutTube custom start time
Test - https://codepen.io/anon/pen/mxapNK?editors=1000
1 parent 2d1e511 commit c33194d

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

dist/jquery.fancybox.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ==================================================
2-
// fancyBox v3.3.2
2+
// fancyBox v3.3.3
33
//
44
// Licensed GPLv3 for open source use
55
// or fancyBox Commercial License for commercial use
@@ -2765,7 +2765,7 @@
27652765
});
27662766

27672767
$.fancybox = {
2768-
version: "3.3.2",
2768+
version: "3.3.3",
27692769
defaults: defaults,
27702770

27712771
// Get current instance and execute a command.
@@ -3253,8 +3253,12 @@
32533253
thumb =
32543254
$.type(providerOpts.thumb) === "function" ? providerOpts.thumb.call(this, rez, params, item) : format(providerOpts.thumb, rez);
32553255

3256-
if (providerName === "vimeo") {
3257-
url = url.replace("&%23", "#");
3256+
if (providerName === "youtube") {
3257+
url = url.replace(/&t=((\d+)m)?(\d+)s/, function(match, p1, m, s) {
3258+
return "&start=" + ((m ? parseInt(m, 10) * 60 : 0) + parseInt(s, 10));
3259+
});
3260+
} else if (providerName === "vimeo") {
3261+
c = url.replace("&%23", "#");
32583262
}
32593263

32603264
return false;

dist/jquery.fancybox.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@fancyapps/fancybox",
33
"description": "Touch enabled, responsive and fully customizable jQuery lightbox script",
4-
"version": "3.3.2",
4+
"version": "3.3.3",
55
"homepage": "http://fancyapps.com/fancybox/",
66
"main": "./dist/jquery.fancybox.js",
77
"author": "fancyApps",

src/js/media.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,12 @@
158158
thumb =
159159
$.type(providerOpts.thumb) === "function" ? providerOpts.thumb.call(this, rez, params, item) : format(providerOpts.thumb, rez);
160160

161-
if (providerName === "vimeo") {
162-
url = url.replace("&%23", "#");
161+
if (providerName === "youtube") {
162+
url = url.replace(/&t=((\d+)m)?(\d+)s/, function(match, p1, m, s) {
163+
return "&start=" + ((m ? parseInt(m, 10) * 60 : 0) + parseInt(s, 10));
164+
});
165+
} else if (providerName === "vimeo") {
166+
c = url.replace("&%23", "#");
163167
}
164168

165169
return false;

0 commit comments

Comments
 (0)