Wednesday 20 May 2015

We can store the images in the list, but we will be giving the URL of the image while store into list. When you try to access the image using CSOM we will get the URL instead of the image.
To get the image using CSOM here we find the path to get it.

clientContext = new SP.ClientContext.get_current();
var vList = clientContext.get_web().get_lists().getByTitle("your listname");
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(‘<view></view>’);
this.collListItem = vList.getItems(camlQuery);   
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this. success),Function.createDelegate(this, thisFailed));


function success(){
try{
var listItemEnumerator = collListItem.getEnumerator();
while(listItemEnumerator.moveNext())
{
var Image = currentItem.get_item('Imagefieldname').get_url();
var html = <img src="'+ Image+’”;
 }
You can show your image now by append it to div or any way you want.


Cheers

0 comments:

Post a Comment