Get all image from a folder in a Picture Library using Rest Api Sharpoint 2013
$.ajax({
method: 'GET',
url: window.location.origin+_spPageContextInfo.webServerRelativeUrl+"/_api/Web/GetFolderByServerRelativeUrl('GSImages/" + ItemId + "')/files",
headers: { "Accept": "application/json;odata=verbose" }
}).success(function (d, s, h, c) {
var result = d["d"]["results"];
if (result.length != 0) {
$.each(result, function (i, j) {
var imageParth = result[i]["ServerRelativeUrl"];
var imageText = result[i]["Title"];
var imageUrl = window.location.origin + imageParth;
strHtml += '<li>';
strHtml += '<img src="' + imageUrl + '" style="background-color:white; width:295px;height:120px;cursor:hand" title="Anil">';
strHtml += '<div style="background-color:#b3b3b3;height:30px;width:295px;padding-top:5px;font-family:Arial, Helvetica, sans-serif;font-size:12px;color:black;"><a href="javascript:void(0)" style="color:#0072c6;" >'+imageText+'</a></div>';
strHtml += '</li>';
});
strHtml += '</ul>';
$('#gsrImgContainer').html(strHtml);
$('#lightSlider').lightSlider({
gallery: true,
item: 3,
loop: true,
});
}
});
method: 'GET',
url: window.location.origin+_spPageContextInfo.webServerRelativeUrl+"/_api/Web/GetFolderByServerRelativeUrl('GSImages/" + ItemId + "')/files",
headers: { "Accept": "application/json;odata=verbose" }
}).success(function (d, s, h, c) {
var result = d["d"]["results"];
if (result.length != 0) {
$.each(result, function (i, j) {
var imageParth = result[i]["ServerRelativeUrl"];
var imageText = result[i]["Title"];
var imageUrl = window.location.origin + imageParth;
strHtml += '<li>';
strHtml += '<img src="' + imageUrl + '" style="background-color:white; width:295px;height:120px;cursor:hand" title="Anil">';
strHtml += '<div style="background-color:#b3b3b3;height:30px;width:295px;padding-top:5px;font-family:Arial, Helvetica, sans-serif;font-size:12px;color:black;"><a href="javascript:void(0)" style="color:#0072c6;" >'+imageText+'</a></div>';
strHtml += '</li>';
});
strHtml += '</ul>';
$('#gsrImgContainer').html(strHtml);
$('#lightSlider').lightSlider({
gallery: true,
item: 3,
loop: true,
});
}
});
Comments