Skip to content

Conversation

@gggordon
Copy link

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.

…any other source by utilizing the library's ability to load config from html5 data attributes. By specifying data-type='local' and including a json string of data in data-image-data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant