jermartin77 / plusgallery

A responsive javascript based image gallery driven by photos from a 3rd party source.
61 stars 35 forks source link

Updated plusgallery.js to accommodate files from a local database or any other source #38

Open gggordon opened 9 years ago

gggordon commented 9 years ago

Updated PlusGallery.js to accommodate other sources

Specifically, plusgallery may now accommodated data from a local database or other sources through the use of two additional attributes.

To utilize this new feature, add the following html5 data attributes:

  1. data-type="local"
  2. data-image-data="json-formatted-string"

NB. json-formatted-string is a json object in the following format

{
    albums: [  //array of albums
        {  //album object
            title:"Album Title", 
            images:[   //array of images in gallery
                 {          //image object
                     src:"", //URL of large image
                     th:"", // URL of image thumbnail
                     caption:"" // caption of images
                 }
            ]
        }
    ]
}

Quick Tip

To obtain json-formatted-string from JSON object, you may write in javascript

JSON.stringify(obj)

Issues

When inserting characters such as the apostrophe (") or single quotation mark ('), please ensure to use html encoded values or alternatives as these may break your html page and will result in the gallery not showing (although no errors will be shown in your console).

Additional Changes

  1. Removed wait for all images to load before being able to see album images. This was quite a bit slow and was already accommodated by a loading image over image tiles.