nanogallery2
nanogallery2 copied to clipboard
If an image hasn't been displayed and you try to delete it, it doesn't get deleted.
The title sums it up. If an image has not been displayed and you try to delete it, it doesn't get deleted.
can you share your code ?
I am initializing the gallery with an no items initially.
`var defaultOpt = {
items : [],
thumbnailWidth: '200px',
thumbnailHeight: '200px;',
thumbnailSelectable : true,
thumbnailToolbarImage : {bottomRight: "share,download", topRight: "custom1"},
icons: {
thumbnailCustomTool1: '<i class="glyphicon glyphicon-trash" aria-hidden="true"></i>',
},
thumbnailHoverEffect2: "imageScaleIn80|toolsAppear|labelAppear",
locationHash: false,
thumbnailDisplayTransition: "slideUp",
selectMode: true,
fnThumbnailToolCustAction: function (action, item ) {
customActions[action](item);
},
fnThumbnailOpen: function ( items ) {
mediaList = items;
mediaIndex =0;
$("#lightbox-modal").modal("show");
renderLightBox()
},
fnGalleryObjectModelBuilt: function () {
for (var i=0; i<initialAssets.length; i++) {
addToGallery(initialAssets[i]);
}
}
},
};`
Then, I am adding the items one by one using the addToGallery Code:
`function addToGallery(asset) {
var url = asset.url;
var ngy2data = $(assetContainer).nanogallery2('data');
var instance = $(assetContainer).nanogallery2('instance');
// create the new item
var ID = ngy2data.items.length + 1;
var albumID = '0';
//signature NGY2Item.New = function( instance, title, description, ID, albumID, kind, tags )#}
var newItem = NGY2Item.New(instance, (asset.order)?'wfm':'not_from', '', ID, albumID, 'image', '' );
// define thumbnail -> image displayed in the gallery
// define URL of the media to display in lightbox
newItem.setMediaURL( url, 'img');
processAsset(asset);
newItem.customAttrs = asset;
newItem.spiralInserted = true;
if (asset.contentType != "image") {
//thumbnail urls for non-image fileformats
var thumbnailUrl = "fileicons/png/"+ asset.url.split(".").pop().substring(0, 3)+".png";
}
newItem.thumbSet( thumbnailUrl || url, 200, 200); // w,h
// currently displayed album
//remove this if condition later
if ( ngy2data.items[ngy2data.gallery.albumIdx].GetID() == 0 ) {
// add new item to current Gallery Object Model (GOM)
newItem.addToGOM();
// refresh the display (-> only once if you add multiple items)
galleryResize();
}
return newItem;
}`
We have a selectAll button, which marks all the items as selected and then I am deleting each item using:
item.delete();
But, then neverDisplayed
items are not being deleted. When I scroll, I can see them.
Also, can we have an option to prepend an item to the gallery?