working with a Lightswitch application and the UI is done in javascript. What I have is a list of attachments, anything from images to pdfs, spreadsheets and regular docs. What I would like to do is separate the images from the rest and wrap them in 'img' tags so they display as images instead of just file attachments.
The postRender function looks like this for my list:
myapp.ViewLesson.LessonAttachments_postRender = function (element, contentItem) {
// Write code here.
var re = /(?:\.([^.]+))?$/;
var ext = re.exec(contentItem.value)[1];
if (ext = "jpg" || "png" || "bmp") {
//wrap each item in '<img>" tags to display them as images
}
};
I tried to filter the extensions by using pieces from this: How to extract extension from filename string in Javascript?
But it's not working