Sorry if this is stupid easy but I'm trying to display user pictures from sharepoint in datatables. I can see the link in JSON data coming back from the ajax query in the "Picture" field so I added:
"aoColumnDefs": [
{"aTargets": [0], "mData": "Picture", "sClass": "center","mRender": function ( data, type, full ) {
return '<img src="'+data+'"></>';
}
},
I get a "broken picture" type black box with an X in it. I'm noticing that I'm getting 2 urls back in that field though so I will try to use substring in the query to clean that up. I'm also wondering if datatables would by default size the rows to fit the pictures, or resize the pictures to fit in the existing row size, or if the pictures not fitting into the row size is what's making them not display.
UPDATE: Thanks to PirateEric I've figured out a way to make this work and add a default picture:
{"aTargets": [0], "mData": "Picture", "sClass": "center","mRender": function ( data, type, full ) {
if(data == null) {
return '<img src="https://linkToADefaultImage.png"></>';
} else {
return '<img src="'+data.split(",")[0]+'"></>';
}
}
},
https://server/..../useranme.jpg,https://server:443/..../username.jpg