-1

I created a Word AddIn that gets WorkItems from TFS and inserts them over an HTML template that the user can alter. It has a similar structure to the Team Tab in Excel. It works perfectly fine now, except for the attachments of a workitem, which are usually pictures. For Word 2013, they are inserted correctly, for Word 2016, they are displayed as empty pictures, but with the correct size. It's not the placeholder setting, they are not empty rectangles, it just shows the picture icon in the corresponding size. I can save them to a local folder, so the picture seems to be there. I get the pictures by creating an html tag for them and downloading them to Temp. This is the html tag code:

var attachmentPath = AttachmentStorage.SaveAttachmentToTemp(attachment);
var imageSize = GetImageData(attachmentPath);
var imageData = ("<img src=\"" + attachmentPath + "\" width=\"" + imageSize[0] + "\" height=\"" + imageSize[1] + "\">");
imagesHtml.Add(imageData);

The imagesHtml string is added to the complete html string of the workitem and inserted into the active document. Anyone got any ideas? Hope my question is relatively clear.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
tweedledum11
  • 121
  • 9

1 Answers1

1

This is a trust issue as it is in general highly unsafe to have access to the local file system from within websites/HTML. See also this thread:

Why can't I do <img src="C:/localfile.jpg">?

Community
  • 1
  • 1
Maarten van Stam
  • 1,901
  • 1
  • 11
  • 16
  • So the only possible workaround is uploading them somewhere? Or inserting them directly from TFS? – tweedledum11 Sep 19 '16 at 13:25
  • When I try to use the Uri from TFS instead of the local file path, I get an exception stating that a URI is not allowed. Do I need to download the file and reupload it somewhere else? – tweedledum11 Sep 19 '16 at 13:37
  • I don't know if it's relevant, but the images are displayed correctly when I save the document and reopen it. – tweedledum11 Sep 20 '16 at 08:59