-1

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

Community
  • 1
  • 1
gibbypoo
  • 55
  • 5
  • 1
    Your comment gives you the best advice... "Write code here". – mccainz Sep 26 '14 at 16:05
  • You have not really asked a SO question. You have asked 'what is the best way' to do something. And, your provided code gives little clue how this could best be done if someone wished to attempt an answer in that vein. Take a shot at implementing a solution and when/if you hit a wall ask a question at that point. – mccainz Sep 26 '14 at 16:16
  • The point is that you have to try something before asking for help. Your question is off-topic otherwise. – isherwood Sep 26 '14 at 16:17
  • Updated with my attempt – gibbypoo Sep 26 '14 at 16:26

1 Answers1

0

You could consider the approach outlined in this article from the Office Developer folks on MSDN. If you build your app as a Cloud Business App and use SharePoint as your document store, the CBA solution will provide the appropriate file placeholder icon for any content known to SharePoint.

I hope this is useful. :)

Ozziemedes
  • 311
  • 1
  • 6