Skip to content

Commit 0a7d0d0

Browse files
committed
Added YouTube and Vimeo player plugins.
Fixed the video loading style. Extended the getDataProperty method to support JSON values as data attributes.
1 parent 739a438 commit 0a7d0d0

15 files changed

+594
-44
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ MINIFY_JS+= js/blueimp-gallery.js
99
MINIFY_JS+= js/blueimp-gallery-fullscreen.js
1010
MINIFY_JS+= js/blueimp-gallery-indicator.js
1111
MINIFY_JS+= js/blueimp-gallery-video.js
12+
MINIFY_JS+= js/blueimp-gallery-vimeo.js
13+
MINIFY_JS+= js/blueimp-gallery-youtube.js
1214

1315
MINIFY_JS_JQUERY=js/blueimp-gallery.js
1416
MINIFY_JS_JQUERY+= js/blueimp-gallery-fullscreen.js
1517
MINIFY_JS_JQUERY+= js/blueimp-gallery-indicator.js
1618
MINIFY_JS_JQUERY+= js/blueimp-gallery-video.js
19+
MINIFY_JS_JQUERY+= js/blueimp-gallery-vimeo.js
20+
MINIFY_JS_JQUERY+= js/blueimp-gallery-youtube.js
1721
MINIFY_JS_JQUERY+= js/jquery.blueimp-gallery.js
1822

1923
default: css js

README.md

Lines changed: 100 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@
1313
- [Carousel options](#carousel-options)
1414
- [Indicator options](#indicator-options)
1515
- [Fullscreen options](#fullscreen-options)
16-
- [Video factory options](#video-factory-options)
16+
- [Video options](#video-options)
17+
- [Video factory options](#video-factory-options)
18+
- [YouTube options](#youtube-options)
19+
- [Vimeo options](#vimeo-options)
1720
- [Container and element options](#container-and-element-options)
1821
- [Property options](#property-options)
1922
- [API](#api)
2023
- [Initialization](#initialization)
2124
- [API methods](#api-methods)
2225
- [Videos](#videos)
26+
- [HTML5 video player](#html5-video-player)
2327
- [Multiple video sources](#multiple-video-sources)
28+
- [YouTube](#youtube)
29+
- [Vimeo](#vimeo)
2430
- [Additional Gallery elements](#additional-gallery-elements)
2531
- [Additional content types](#additional-content-types)
2632
- [Example HTML text factory implementation](#example-html-text-factory-implementation)
@@ -373,7 +379,9 @@ var fullscreenOptions = {
373379
};
374380
```
375381

376-
### Video factory options
382+
### Video options
383+
384+
#### Video factory options
377385
The following are the additional default options set for the video factory:
378386

379387
```js
@@ -390,6 +398,33 @@ var videoFactoryOptions = {
390398
videoSourcesProperty: 'sources'
391399
};
392400
```
401+
#### YouTube options
402+
Options for [YouTube](https://www.youtube.com/) videos:
403+
404+
```js
405+
var youTubeOptions = {
406+
// The list object property (or data attribute) with the YouTube video id:
407+
youTubeVideoIdProperty: 'youtube',
408+
// Optional object with parameters passed to the YouTube video player:
409+
// https://developers.google.com/youtube/player_parameters
410+
youTubePlayerVars: undefined
411+
};
412+
```
413+
414+
#### Vimeo options
415+
Options for [Vimeo](https://vimeo.com/) videos:
416+
417+
```js
418+
var youTubeOptions = {
419+
// The list object property (or data attribute) with the Vimeo video id:
420+
vimeoVideoIdProperty: 'vimeo',
421+
// The URL for the Vimeo video player, can be extended with custom parameters:
422+
// https://developer.vimeo.com/player/embedding
423+
vimeoPlayerUrl: '//player.vimeo.com/video/VIDEO_ID?api=1&player_id=PLAYER_ID',
424+
// The prefix for the Vimeo video player ID:
425+
vimeoPlayerIdPrefix: 'vimeo-player-'
426+
};
427+
```
393428

394429
### Container and element options
395430
The widget **container** option can be set as id string (with "#" as prefix) or element node, so the following are equivalent:
@@ -487,6 +522,8 @@ var gallery = blueimp.Gallery([
487522

488523
The URL property name defined by each list object can be configured via the **urlProperty** option. By default, it is set to **href**, which allows to pass a list of HTML link elements as first argument.
489524

525+
For images, the **thumbnail** property defines the URL of the image thumbnail, which is used for the indicator navigation displayed at the bottom of the Gallery, if the controls are visible.
526+
490527
The object returned by executing the Gallery function (the **gallery** variable in the example code above) is a new instance of the Gallery and allows to access the public [API methods](#api-methods) provided by the Gallery.
491528
The Gallery initialization function returns **false** if the given list was empty, the Gallery widget is missing, or the browser doesn't pass the functionality test.
492529

@@ -523,6 +560,9 @@ gallery.close();
523560
```
524561

525562
### Videos
563+
564+
#### HTML5 video player
565+
526566
The Gallery can be initialized with a list of videos instead of images, or a combination of both:
527567

528568
```js
@@ -543,9 +583,8 @@ blueimp.Gallery([
543583
```
544584

545585
The Gallery uses the **type** property to determine the content type of the object to display.
546-
If the type property is empty or doesn't exist, the default type **image** is assumed.
547-
548-
For images, the **thumbnail** property defines the URL of the image thumbnail, which is used for the indicator navigation displayed at the bottom of the Gallery, if the controls are visible.
586+
If the type property is empty or doesn't exist, the default type **image** is assumed.
587+
Objects with a video type will be displayed in a [HTML5 video element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) if the browser supports the video content type.
549588

550589
For videos, the **poster** property defines the URL of the poster image to display, before the video is started.
551590

@@ -586,6 +625,52 @@ It is also possible to define the video sources as data-attribute on a link elem
586625
</div>
587626
```
588627

628+
#### YouTube
629+
The Gallery can display [YouTube](https://www.youtube.com/) videos for Gallery items with a **type** of **text/html** and a **youtube** property (configurable via [YouTube options](#youtube-options)) with the YouTube video-ID:
630+
631+
```js
632+
blueimp.Gallery([
633+
{
634+
title: 'A YouYube video',
635+
href: 'https://www.youtube.com/watch?v=VIDEO_ID',
636+
type: 'text/html',
637+
youtube: 'VIDEO_ID',
638+
poster: 'https://img.youtube.com/vi/VIDEO_ID/0.jpg'
639+
},
640+
{
641+
title: 'Banana',
642+
href: 'http://example.org/images/banana.jpg',
643+
type: 'image/jpeg',
644+
thumbnail: 'http://example.org/thumbnails/banana.jpg'
645+
}
646+
]);
647+
```
648+
649+
Please note that the Gallery YouTube integration requires a browser with [postMessage](https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage) support, which excludes IE7.
650+
651+
#### Vimeo
652+
The Gallery can display [Vimeo](https://vimeo.com/) videos for Gallery items with a **type** of **text/html** and a **vimeo** property (configurable via [Vimeo options](#vimeo-options)) with the Vimeo video-ID:
653+
654+
```js
655+
blueimp.Gallery([
656+
{
657+
title: 'A Vimeo video',
658+
href: 'https://vimeo.com/VIDEO_ID',
659+
type: 'text/html',
660+
vimeo: 'VIDEO_ID',
661+
poster: 'https://secure-b.vimeocdn.com/ts/POSTER_ID.jpg'
662+
},
663+
{
664+
title: 'Banana',
665+
href: 'http://example.org/images/banana.jpg',
666+
type: 'image/jpeg',
667+
thumbnail: 'http://example.org/thumbnails/banana.jpg'
668+
}
669+
]);
670+
```
671+
672+
Please note that the Gallery Vimeo integration requires a browser with [postMessage](https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage) support, which excludes IE7.
673+
589674
### Additional Gallery elements
590675
It is possible to add additional elements to the Gallery widget, e.g. a description label.
591676

@@ -654,7 +739,9 @@ The Gallery uses the **type** property of each content object to determine which
654739
The main type (the string in front of the slash, **text** in the example above) is concatenated with the string **Factory** to create the factory method name, e.g. **textFactory**.
655740

656741
#### Example HTML text factory implementation
657-
Please note that although blueimp Gallery doesn't require [jQuery](http://jquery.com/), the following example uses it for convenience.
742+
Please note that the textFactory script has to be included after the core Gallery script, but before including the [YouTube](#youtube) and [Vimeo](#vimeo) integration plugins, which extend the textFactory implementation to handle YouTube and Vimeo video links.
743+
744+
Please also note that although blueimp Gallery doesn't require [jQuery](http://jquery.com/), the following example uses it for convenience.
658745

659746
Extend the Gallery prototype with the **textFactory** method:
660747

@@ -681,7 +768,7 @@ blueimp.Gallery.prototype.textFactory = function (obj, callback) {
681768
};
682769
```
683770

684-
Add the **text-content** class to the Gallery CSS:
771+
Next, add the **text-content** class to the Gallery CSS:
685772

686773
```css
687774
.blueimp-gallery > .slides > .slide > .text-content {
@@ -837,19 +924,23 @@ You can also use the individual source files instead of the standalone minified
837924
<script src="js/blueimp-gallery-fullscreen.js"></script>
838925
<script src="js/blueimp-gallery-indicator.js"></script>
839926
<script src="js/blueimp-gallery-video.js"></script>
927+
<script src="js/blueimp-gallery-youtube.js"></script>
928+
<script src="js/blueimp-gallery-vimeo.js"></script>
840929
```
841930

842931
The helper script can be replaced by [jQuery](http://jquery.com/) v. 1.7+.
843-
The fullscreen, indicator and video source files are optional if their functionality is not required.
932+
The fullscreen, indicator, video, youtube and vimeo source files are optional if their functionality is not required.
844933

845-
The [jQuery plugin](#jquery-plugin) requires [jQuery](http://jquery.com/) v. 1.7+ and the basic Gallery script, while the fullscreen, indicator and video source files are also optional:
934+
The [jQuery plugin](#jquery-plugin) requires [jQuery](http://jquery.com/) v. 1.7+ and the basic Gallery script, while the fullscreen, indicator, video, youtube and vimeo source files are also optional:
846935

847936
```html
848937
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
849938
<script src="js/blueimp-gallery.js"></script>
850939
<script src="js/blueimp-gallery-fullscreen.js"></script>
851940
<script src="js/blueimp-gallery-indicator.js"></script>
852941
<script src="js/blueimp-gallery-video.js"></script>
942+
<script src="js/blueimp-gallery-youtube.js"></script>
943+
<script src="js/blueimp-gallery-vimeo.js"></script>
853944
<script src="js/jquery.blueimp-gallery.js"></script>
854945
```
855946

blueimp-gallery.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blueimp-gallery",
3-
"version": "2.9.0",
3+
"version": "2.10.0",
44
"title": "blueimp Gallery",
55
"description": "blueimp Gallery is a touch-enabled, responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers. It features swipe, mouse and keyboard navigation, transition effects, slideshow functionality, fullscreen support and on-demand content loading and can be extended to display additional content types.",
66
"keywords": [

bower.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blueimp-gallery",
3-
"version": "2.9.0",
3+
"version": "2.10.0",
44
"title": "blueimp Gallery",
55
"description": "blueimp Gallery is a touch-enabled, responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers. It features swipe, mouse and keyboard navigation, transition effects, slideshow functionality, fullscreen support and on-demand content loading and can be extended to display additional content types.",
66
"keywords": [
@@ -63,6 +63,8 @@
6363
"./js/blueimp-gallery.js",
6464
"./js/blueimp-gallery-fullscreen.js",
6565
"./js/blueimp-gallery-indicator.js",
66-
"./js/blueimp-gallery-video.js"
66+
"./js/blueimp-gallery-video.js",
67+
"./js/blueimp-gallery-vimeo.js",
68+
"./js/blueimp-gallery-youtube.js"
6769
]
6870
}

css/blueimp-gallery-video.css

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@charset 'UTF-8';
22
/*
3-
* blueimp Gallery Video Factory CSS 1.0.0
3+
* blueimp Gallery Video Factory CSS 1.1.0
44
* https://github.com/blueimp/Gallery
55
*
66
* Copyright 2013, Sebastian Tschan
@@ -17,15 +17,23 @@
1717
right: 0;
1818
bottom: 0;
1919
left: 0;
20-
/* Prevent artifacts in Mozilla Firefox: */
21-
-moz-backface-visibility: hidden;
22-
}
23-
.blueimp-gallery > .slides > .slide > .video-content > video,
24-
.blueimp-gallery > .slides > .slide > .video-content > img {
2520
margin: auto;
2621
max-width: 100%;
2722
max-height: 100%;
2823
opacity: 1;
24+
/* Prevent artifacts in Mozilla Firefox: */
25+
-moz-backface-visibility: hidden;
26+
}
27+
.blueimp-gallery > .slides > .slide > .video-content > iframe {
28+
width: 100%;
29+
height: 100%;
30+
border: none;
31+
position: absolute;
32+
top: 100%;
33+
left: 0;
34+
}
35+
.blueimp-gallery > .slides > .slide > .video-playing > iframe {
36+
top: 0;
2937
}
3038
.blueimp-gallery > .slides > .slide > .video-content > a {
3139
position: absolute;
@@ -55,7 +63,7 @@
5563
}
5664

5765
/* Replace PNGs with SVGs for capable browsers (excluding IE<9) */
58-
body:last-child .blueimp-gallery > .slides > .slide > .video-content > a {
66+
body:last-child .blueimp-gallery > .slides > .slide > .video-content:not(.video-loading) > a {
5967
background-image: url(../img/video-play.svg);
6068
}
6169

0 commit comments

Comments
 (0)