generate image based on id
generate image based on id
I need to generate an image based on the record user_id. However, not all users have an image, and I need to then display a default "Image Not Found" image in its place.
This is the code used to generate the image, and make the name a link to a view page:
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(0)', nRow).html('<img width="100px" src="https://my.photos.com/photos/' + aData[0] + '.jpg"><a href="view.php?user_id=' + aData[0] + '">' + aData[1] + '</a>');
return nRow;
},
any help is appreciated.
Answers
Can you do a check for
aData[0] === null
or similar. If so, that would be the way to do it.Allan