On this page, you will learn how to configure different kind of media content for your gallery and lightbox.
A content source is a place where your images, videos and albums are stored. As for layout settings, definition can be made with HTML markup or can be passed in javascript to the nanogallery2()
function.
Natively, you can display self hosted images, self hosted videos (WEBM and OGV) and videos hosted on Youtube, Vimeo or Dailymotion, just by listing all your medias individually in your HTML page.
Additionally, you can use an optional module/service which will send the medias to your gallery:
nanoPhotosProvider2 - for self hosted images, with automatic generation of responsive thumbnails
Flickr
Google Photos
Content source is defined on gallery initialization:
use the data-nanogallery2
attribute.
<div data-nanogallery2 = '{ <!-- ### gallery settings ### --> "thumbnailHeight": 150, "thumbnailWidth": 150, "itemsBaseURL": "http://nanogallery2.nanostudio.org/samples/" }'> <!-- ### gallery content ### --> <a href="img_01.jpg" data-ngthumb="img_01t.jpg">Title Image 1</a> <a href="img_02.jpg" data-ngthumb="img_02t.jpg">Title Image 2</a> <a href="img_03.jpg" data-ngthumb="img_03t.jpg">Title Image 3</a> </div>
settings are passed to the nanogallery2()
function.
$("#my_nanogallery2").nanogallery2({ <!-- ### gallery settings ### --> thumbnailHeight: 150, thumbnailWidth: 150, itemsBaseURL: 'http://nanogallery2.nanostudio.org/samples/', <!-- ### gallery content ### --> items: [ { src: 'img_01.jpg', srct: 'img_01t.jpg', title: 'Title Image 1' }, { src: 'img_02.jpg', srct: 'img_02t.jpg', title: 'Title Image 2' }, { src: 'img_03.jpg', srct: 'img_03t.jpg', title: 'Title Image 3' } ] });
For images, videos and albums.
You need one HTML element which contains sub-elements representing the medias. Any kind of markup can be used.
URL to medias and thumbnail's images are extracted from the standard HREF and SRC attributes.
Dedicated nanogalley2 data-attributes can be used on all kind of HTML elements:
- data-ngsrc: URL to big image or video
- data-ngthumb: URL to thumbnail image
- data-ngdesc: media description
...
Check the markup reference guide for the full list of supported attributes.
Some examples:
<div id="my_nanogallery2" data-nanogallery2 = '{ "itemsBaseURL": "https://mywebserver/gallery/myimages/"}' > <a href="img_01.jpg" data-ngthumb="img_01t.jpg" data-ngdesc="Description1" >Title Image1</a> <a href="img_02.jpg" data-ngthumb="img_02ts.jpg" data-ngdesc="Image 2 description" >Title Image2</a> <a href="img_03.jpg" data-ngthumb="img_03t.jpg" >Title Image3</a> </div>Note: you may use the option
itemsBaseURL
to define the base URL where medias are stored.<div id="my_nanogallery2" data-nanogallery2 > <a href="img/img_01.jpg">Title Image 2 <img src="img/img_01_thumbnail.jpg"/> </a> <a href="img/img_02.jpg">Title Image 2 <img src="img/img_02_thumbnail.jpg"/> </a> <a href="img/img_03.jpg">Title Image 3 <img src="img/img_03_thumbnail.jpg"/> </a> </div>
Albums are defined like images/videos. A thumbnail image is required, but no large image. Must also be set for each album:
- the kind of the element: data-ngkind="album"
- an unique ID: use the HTML ID
attribute or the data-ngid
attribute
To assign an item (image, video or album) to an album, use the attribute data-ngalbumid
to point to that album.
<div id="my_nanogallery2" data-nanogallery2 = '{ "itemsBaseURL": "https://mywebserver/gallery/myimages/"}' > <!-- FIRST ALBUM --> <a href="" data-ngkind="album" data-ngid="1" data-ngthumb="img01Ta.jpg" >Album A</a> <a href="img02a.jpg" data-ngid="10" data-ngalbumid="1" data-ngthumb="img02Ta.jpg" >Image 1 / album A</a> <a href="img03a.jpg" data-ngid="11" data-ngalbumid="1" data-ngthumb="img03Ta.jpg" >Image 2 / album A</a> <!-- SECOND ALBUM --> <a href="" data-ngkind="album" data-ngid="2" data-ngthumb="image_02t.jpg" >Album B</a> <a href="img02.jpg" data-ngid="20" data-ngalbumid="2" data-ngthumb="img02T.jpg" >Image1</a> <a href="img03.jpg" data-ngid="21" data-ngalbumid="2" data-ngthumb="img03T.jpg" >Image2</a> <a href="img04.jpg" data-ngid="22" data-ngalbumid="2" data-ngthumb="img04T.jpg" >Image3</a> </div>
Videos are defined like images.
Define the URL of each video. Thumbnails are retrieved automatically for Youtube and Dailymotion. For Vimeo, you have to set the URL of the video's thumbnail.
Supported video platforms: Youtube, Vimeo and Dailymotion.
<div id="my_nanogallery2" data-nanogallery2> <a href="https://www.youtube.com/watch?v=Ir098VWCv8Q" >Youtube</a> <a href="http://www.dailymotion.com/video/x4wtyl6" >Dailymotion</a> <a href="https://vimeo.com/32875422" data-ngthumb="https://i.vimeocdn.com/video/222726041_1280x720.jpg" >Vimeo</a> <a href="my_video.mp4" data-ngthumb="my_video_thumbnail.jpg" >Self hosted</a> </div>
Videos, images and album can be conbined in a single gallery.
<div id="my_nanogallery2" data-nanogallery2 = '{ "itemsBaseURL": "https://mywebserver/gallery/myimages/"}' > <a href="https://www.youtube.com/watch?v=Ir098VWCv8Q" >Youtube</a> <a href="my_video.mp4" data-ngthumb="my_video_thumbnail.jpg" >Self hosted video</a> <a href="img_01.jpg" data-ngthumb="img_01t.jpg" >Title Image1</a> </div>
The lightbox can be used standalone, without gallery. Set the attribute data-nanogallery2-lightbox
.
<img src = "thumbnail_image_1.jpg" data-ngsrc = "big_image_1.jpg" data-nanogallery2-lightbox = '{ "viewerToolbar": { "display": false } }' /> <img src="thumbnail_image_2.jpg" data-ngsrc="big_image_2.jpg" data-nanogallery2-lightbox /> <img src="thumbnail_image_3.jpg" data-ngsrc="big_image_3.jpg" data-nanogallery2-lightbox />
This is the list of supported attributes to define one media (image, video or album).
property | default | description |
---|---|---|
data-ngsrc href stringv1.0 |
URL to big image or video. | |
data-ngimageWidth
data-ngimageHeight integerv1.0 |
0 |
Width and height of the big image (in pixels). Not used for videos.
Not mandatory, but should be defined to improve overall performances and user experience.
|
data-ngthumb src href stringv1.0 |
URL of the thumbnail image. Big image URL will be used if not defined. Thumbnail can be retrieved automatically for videos hosted on Youtube or Dailymotion, but you can also define your own one. |
|
data-ngthumbImgWidth
data-ngthumbImgHeight integerv1.0 |
0 |
Width and height of the thumbnail image (in pixels).
Not mandatory, but setting is HIGHLY recommended to improve overall performances and user experience.
|
element value alt stringv3.0 |
Item's title. | |
data-ngdesc
stringv1.0 |
Item's description. | |
data-ngid id integerstringv1.0 |
Item's ID. MANDATORY if your gallery contains albums -> assign an ID to each item (image and album).
|
|
data-ngalbumid
integerstringv1.0 |
ID of the album containing the item.
MANDATORY if your gallery contains albums.
|
|
data-ngkind
stringv1.0 |
"image" |
Item's kind. Possible values:
- "image": for media (image or video) - "album": for album |
data-ngdest
stringv1.0 |
Destination URL on thumbnail click (instead of displaying an image/video, the user is redirected to the specified URL). | |
data-ngimagedominantcolor
stringv1.3 |
Thumbnail's image dominant color. RGB value in HEX-format.
This color is used as background for thumbnail images. It may be visible before an image is fully displayed. Example: "data-ngimagedominantcolor": "#808080"
|
|
data-ngimagedominantcolors
base64-stringv1.3 |
Thumbnail's image dominant colors (gradient/blurred image).
Set a very small base64 encoded GIF image. This color is used as background for thumbnail images. It may be visible before an image is fully displayed. Example: "data-ngimagedominantcolors": "data:image/gif;base64,R0lGODdhAwADAOMAAMnjXJi..........."
|
|
data-ngcustomData
objectv1.2 |
Object to store custom data.
Example: "data-ngcustomData" = '{ "property1": "value1", "property2": "value2" }'
|
|
data-ngtags
stringv1.0 |
Image tags - used for filtering | |
data-ngexifmodel data-ngexifflash data-ngexiffocallength data-ngexiffstop data-ngexifexposure data-ngexifiso data-ngexiftime stringv1.0 |
Exif metadata | |
data-ngexiflocation
stringv1.0 |
Exif location This value is used to display the image location with Google Maps on the image info window. Use a format supported by Google Maps. |
|
data-ngdownloadurl
stringv1.2 |
URL to define a specific image for download |
For images, videos and albums
Images, videos and albums are defined on gallery initialization, using an array of javascript objects.
Check the reference guide for the full list of supported properties.
Some examples:
<div id="my_nanogallery2" data-nanogallery2></div> <script> $(document).ready(function () { $("#my_nanogallery2").nanogallery2({ items: [ { src: 'image_01.jpg', // image url srct: 'image_01ts.jpg', // thumbnail url title: 'Title Image1', // media title description: 'Description1' // media description }, { src: 'image_02.jpg', srct: 'image_02t.jpg', title: 'Title Image2' }, { src: 'image_03.jpg', srct: 'image_03ts.jpg', title: 'Title Image3' } ] }); }); </script>
Albums are defined like images or videos. Define the URL of each video. Thumbnails are retrieved automatically for Youtube and Dailymotion. For Vimeo, you have to set the URL of the video's thumbnail.
Must also be set for each album:
- the property kind: kind: 'album'
- an unique ID: use the property ID
To assign an item (image, video or album) to an album, use the property albumID
to point to the album.
<div id="my_nanogallery2" data-nanogallery2></div> <script> $(document).ready(function () { $("#my_nanogallery2 ").nanogallery2({ items: [ // album 1 { src: 'image_01.jpg', title: 'album A', ID: 1, kind:'album' }, { src: 'image_01.jpg', srct: 'image_01ts.jpg', title: 'image A1', ID: 10, albumID: 1 }, { src: 'image_02.jpg', srct: 'image_02ts.jpg', title: 'image A2', ID: 11, albumID: 1 }, { src: 'image_03.jpg', srct: 'image_03ts.jpg', title: 'image A3', ID: 12, albumID: 1 }, // album 2 { src: 'image_02.jpg', title: 'album B', ID: 2, kind:'album' }, { src: 'image_01.jpg', srct: 'image_01ts.jpg', title: 'image B1', ID: 20, albumID: 2 }, { src: 'image_02.jpg', srct: 'image_02ts.jpg', title: 'image B2', ID: 21, albumID: 2 }, { src: 'image_03.jpg', srct: 'image_03ts.jpg', title: 'image B3', ID: 22, albumID: 2 } ] }); }); </script>
Videos are defined like images.
Define the URL of each video. Thumbnails are retrieved automatically for Youtube and Dailymotion. For Vimeo and for self hoset videos, you have to set the URL of the video's thumbnail.
Supported video platforms: Youtube, Vimeo and Dailymotion.
<div id="my_nanogallery2" data-nanogallery2></div> <script> $(document).ready(function () { $("#my_nanogallery2").nanogallery2({ items: [ { src: 'https://vimeo.com/32875422', // video url srct: 'https://i.vimeocdn.com/video/222726041_1280x720.jpg', // video thumbnail url title: 'Vimeo video', // video title description: 'Video' // video description }, { src: 'https://www.youtube.com/watch?v=Ir098VWCv8Q', title: 'Youtube video' }, { src: 'http://www.dailymotion.com/video/x4wtyl6', title: 'Dailymotion video' }, ] }); }); </script>
Videos, images and album can be conbined in a single gallery.
<div id="my_nanogallery2" data-nanogallery2></div> <script> $(document).ready(function () { $("#my_nanogallery2").nanogallery2({ items: [ { src: 'https://vimeo.com/32875422', // media url srct: 'https://i.vimeocdn.com/video/222726041_1280x720.jpg', // media thumbnail url title: 'Vimeo video', // media title description: 'Video' // media description }, { src: 'https://www.youtube.com/watch?v=Ir098VWCv8Q', title: 'Youtube video' }, { src: 'http://www.dailymotion.com/video/x4wtyl6', title: 'Dailymotion video' }, { src: 'image_01.jpg', srct: 'image_01ts.jpg', title: 'Title Image' } ] }); }); </script>
This is the list of supported properties for defining one media (image, video or album). The properties are case-sensitive. An item object is an image, a video or an album.
property | default | description |
---|---|---|
src
stringv1.0 |
URL to big image or video. | |
height width integerv1.0 |
0 |
Height and width of the big image (in pixels).
Not mandatory, but should be defined to improve overall performances and user experience.
|
srct
stringv1.0 |
URL of the thumbnail image. Big image URL will be used if this parameter is not defined. |
|
imgtHeight imgtWidth integerv1.0 |
0 |
Height and width of the thumbnail image (in pixels).
Not mandatory, but setting is HIGHLY recommended to improve overall performances and user experience.
|
title
stringv1.0 |
Title of the item. | |
description
stringv1.0 |
Description of the item | |
kind
stringv1.0 |
'image' |
Item's kind. Possible values:
- "image": for a media (image or video) - "album": for an album |
ID
integerstringv1.0 |
Item ID. MANDATORY if your gallery contains albums -> assign an ID to each item (image and album).
|
|
albumID
integerstringv1.0 |
ID of the album containing the item. MANDATORY if your gallery contains albums.
|
|
tags
stringv1.0 |
Tags/keywords of the element - used for filtering. | |
imageDominantColor
stringv1.3 |
Thumbnail's image dominant color. RGB value in HEX-format.
This color is used as background for thumbnail images. It may be visible before an image is fully displayed. Example: imageDominantColor: '#808080'
|
|
imageDominantColors
stringv1.3 |
Thumbnail's image dominant colors (gradient/blurred image).
Set a very small base64 encoded GIF image. This color is used as background for thumbnail images. It may be visible before an image is fully displayed. Example: imageDominantColors: 'data:image/gif;base64,R0lGODdhAwADAOMAAMnjXJi..................'
|
|
exifModel exifFlash exifFocalLength exifFStop exifExposure exifIso stringv1.0 |
Exif metadata | |
exifLocation
stringv1.0 |
Exif location - this value is used to display the image location with Google Maps on the image info window.
Use a format supported by Google Maps. |
|
destURL
stringv1.0 |
Destination URL on thumbnail click (instead of displaying a media in the lightbox, the user is redirected to the specified URL). | |
customData
objectv1.0 |
Object to store custom data.
Example: {src: 'img.jpg', srct: 'imgt.jpg', title: 'image01', customData:{prop1: val1, prop1: val2} }
|
|
downloadURL
stringv1.2 |
URL to define a specific image for download |
For images and albums stored on your PHP webserver.
nanoPhotosProvider2 is a PHP application for your webserver. Very easy to setup, it provides images and albums automatically to nanogallery2.
Thumbnails for all nanogallery2 layouts (grid, justified, cascading and mosaic) are automatically generated.
Blurred preview images are used for a really nice effect.
Usage:
- start by installing nanoPhotosProvider2 on your PHP web server. Follow the installation steps on the nanoPhotosProvider2 homepage.
- then configure your HTML page for displaying the gallery:
<div id="nanogallery2" data-nanogallery2='{ "kind": "nano_photos_provider2", "dataProvider": "http://mywebsever.com/nano_photos_provider2/nano_photos_provider2.php", "thumbnailHeight": 150, "thumbnailWidth": 150 }'> </div>
jQuery("#nanogallery2").nanogallery2({ kind: 'nano_photos_provider2', dataProvider: 'http://mywebsever.com/nano_photos_provider2/nano_photos_provider2.php', thumbnailHeight: 150, thumbnailWidth: 150 });
This is an optional module. To use it, include in your HTML page:
jquery.nanogallery2.core.min.js
and jquery.nanogallery2.data_nano_photos_provider2.min.js
jquery.nanogallery2.min.js
property | default | description |
---|---|---|
kind
stringv1.3 |
MANDATORY Storage type. Must be set to 'nano_photos_provider2' to access nanoPhotosProvider2 data.
|
|
dataProvider
stringv1.3 |
MANDATORY URL of your nanoPhotosProvider2 installation. Example: dataProvider: 'http://mywebsever.com/nano_photos_provider2/nano_photos_provider2.php'
|
|
blockListv3.0string |
List of keywords to ignore - album's name containing one of the keywords in the title will be ignored. Keyword separator is | |
|
allowListv3.0string |
List of keywords to authorize - album's name must contain one of the keywords to be displayed. Keyword separator is | |
|
album photoset stringv1.4 |
To display only the content of one specific album/folder. note: 'photoset' is an alias of 'album' |
|
albumList2
stringarray v1.4 |
The list of albums to display. Use a string to set a single album, or an array for multiple albums. Example: One album: albumList2: 'architecture' Three albums: albumList2: ['architecture', 'friends', 'into the wild'] |
nanogallery2 can display your Flickr albums, the content of a specific album, or your full photostream.
This feature is provided "as-is". nanogallery2 is not affiliated to Flickr. Changes by Flickr may affect your galleries. nanogallery2 can not be held responsible for any issue caused by any change on Flickr.
<div id="nanogallery2" data-nanogallery2='{ "kind": "flickr", "userID": "YOUR_FLICKR_ID", "flickrAPIKey": "YOUR_FLICKR_API_KEY", "thumbnailHeight": 150, "thumbnailWidth": 150 }'> </div>
jQuery("#nanogallery2").nanogallery2({ kind: 'flickr', userID: 'YOUR_FLICKR_ID', flickrAPIKey: 'YOUR_FLICKR_API_KEY', thumbnailHeight: 150, thumbnailWidth: 150 });
This is an optional module. To use it, include in your HTML page:
jquery.nanogallery2.core.min.js
and jquery.nanogallery2.data_flickr.min.js
jquery.nanogallery2.min.js
Demonstration:
See the Pen nanogallery2 - Fickr content source by Christophe Brisbois (@Kris-B) on CodePen.
property | default | description |
---|---|---|
kind
stringv1.0 |
Storage type. Must be set to 'flickr' to access Flickr data.
MANDATORY.
|
|
flickrAPIKey
stringv3.0.2 |
Your personal Flickr API key.
MANDATORY. To request one: check this page
|
|
userID
stringv1.0 |
The Flickr user account ID.
MANDATORY.
To retrieve your Flickr user ID: check this page
|
|
album photoset stringv1.0 |
Photoset ID - to display only the content (=the images) of one specific photoset. If set to 'none' , all pictures of the photostream are displayed.
note: 'photoset' is an alias of 'album' |
|
blockListv3.0string |
List of keywords to ignore - albums containing one of the keywords in the title will be ignored.
Keyword separator is |
|
|
tagBlockListv3.0string |
List of tags to ignore - images with meta data containing one of tag will be ignored. | |
allowListv3.0string |
List of keywords to authorize - albums must contain one of the keywords to be displayed.
Keyword separator is |
|
|
albumList2
stringarrayv1.0 |
The list of albums to display. You can specify an album name or it's ID. Use a string to set a single album, or an array for multiple albums. Example: One album: albumList2: 'architecture' Three albums: albumList2: ['architecture', 'friends', '5851968929721015169'] |
|
flickrSkipOriginal
booleanv1.0 |
true | Do not display the original uploaded image (e.g. to avoid rotation issue). |
thumbnailOpenOriginal
booleanv1.0 |
false | Displays the original image in Flickr, without opening the lightbox. |
thumbnailCropScaleFactor
decimalv1.0 |
1.5 |
Activating the crop option to avoid black image borders may scale the thumbnail image up. For this case and to avoid quality loss, the thumbnailCropScaleFactor will be applied to the thumbnail size to get a better image quality.
|
nanogallery2 can display the content of photo albums created on Google Photos.
The setup of this optional module requires advanced javascript skills.
This feature is provided "as-is". nanogallery2 is not affiliated to Google. Changes by Google may affect your galleries. nanogallery2 can not be held responsible for any issue caused by any change on Google Photos.
Note: since february 9, 2017, Google Photos can no more be accessed without account owner's explicit authorization.
nanogallery2 requires a permanent authorization, which is only possible for server side applications.
To solve this issue, you need to use the server module NANOGP2 (more here) .
Usage:
<div id="nanogallery2" data-nanogallery2='{ "kind": "google2", "userID": "111186676244625461692", "google2URL": "https://YOUR_WEB_SERVER/nanogp/nanogp.php", "thumbnailHeight": 150, "thumbnailWidth": 150 }'> </div>Javascript example
jQuery("#nanogallery2").nanogallery2({ kind: 'google2', userID: '111186676244625461692', google2URL: 'https://YOUR_WEB_SERVER/nanogp/nanogp.php', thumbnailHeight: 150, thumbnailWidth: 150 });
This is an optional module. To use it, include in your HTML page:
jquery.nanogallery2.core.min.js
and jquery.nanogallery2.data_google2.min.js
jquery.nanogallery2.min.js
By default, all your albums are displayed. Image description field is not supported.
property | default | description |
---|---|---|
kind
stringv1.0 |
MANDATORY Storage type. Must be set to 'google2' to access Google Photos data. |
|
userID
stringv1.0 |
MANDATORY The Google Photos / Google+ user account ID. |
|
google2URL
stringv1.0 |
MANDATORY The URL pointing to your nanogp installation. Example: google2URL: 'https://mywebsever/nanogp/nanogp.php'
|
|
album
stringv1.0 |
To display the content (= the photos) of one single album. Set the Album ID. Example: album: '5851968929721015169'
Private albums - no more available since Google API changed |
|
albumList2
stringarrayv1.0 |
The list of albums to display. You can specify an album name or it's ID. Use a string to set a single album, or an array for multiple albums. Example: One album: albumList2: 'architecture' Three albums: albumList2: ['architecture', 'friends', '5851968929721015169'] Private albums - no more available since Google API changed |
|
blockListv3.0string |
'scrapbook|profil' |
List of keywords to ignore - album's name containing one of the keywords in the title will be ignored. Keyword separator is | |
allowListv3.0string |
List of keywords to authorize - album's name must contain one of the keywords to be displayed. Keyword separator is | |
|
viewerZoom
booleanv1.0 |
true |
Enables/disables image zoom in lightbox
If disabled, then the image size corresponding to the user screen resolution will be downloaded, instead of the full-resolution one. |
thumbnailCropScaleFactor
decimalv1.0 |
1.5 |
Activating the crop option to avoid black image borders may scale the thumbnail image up. For this case and to avoid quality loss, the thumbnailCropScaleFactor will be applied to the thumbnail size to get a better image quality.
|