# Link to Media in Template node (HTML)

**URL:** <https://discourse.nodered.org/t/link-to-media-in-template-node-html/37693>\
**Category:** Dashboard\
**Created:** [18 December 2020 07:26 UTC](https://discourse.nodered.org/t/link-to-media-in-template-node-html/37693 "2020-12-18T07:26:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [18 December 2020 07:26 UTC](https://discourse.nodered.org/t/link-to-media-in-template-node-html/37693/1 "2020-12-18T07:26:57Z")

</div>

Hello,  
i hope its ok that i ask that question here, i didnt found an answer yet.

I would like to link Media in my Intranet on a HTML Table.

My template Node gets the data from a function node with following code:

```auto
let arr = []
let obj

var Grundpfad = " file:\\\\\\sourcepath to the media";
var k = 0 //Komponentenzähler

for(k=0;k<1000;k++){
    if(msg.payload[k]){
    }else{
         break
    }
}
 
function isNull() {
    for (var i = 0; i < arguments.length; i++) {
        if (
            typeof arguments[i] !== 'undefined'
            && arguments[i] !== undefined
            && arguments[i] != null
            && arguments[i] != NaN
            && arguments[i] 
        ) return arguments[i];
      }
} 
 
    
for(let i=0;i<k;i++){
    obj = {}
    obj.Device_Name = msg.payload[i].Device_Name
    obj.Device_Nr = msg.payload[i].Device_Nr
    obj.Device_Serial = msg.payload[i].Device_Serial
    obj.Device_Type = msg.payload[i].Device_Type
    obj.Booking_DateTime = msg.payload[i].Booking_DateTime
    obj.Booking_Remarks = msg.payload[i].Booking_Remarks
    obj.Location_Name = msg.payload[i].Location_Name
    if(isNull(msg.payload[i].Documents)){
    obj.Documents = "<a href=" + Grundpfad + msg.payload[i].Documents + "</a>"//the last part of the path
    }else{
    obj.Documents = "Kein Dokument hinterlegt" 
    }
    arr.push(obj)
}

const komps = arr;

function compare(a, b) {
  const Device_TypeA = a.Device_Type.toUpperCase();
  const Device_TypeB = b.Device_Type.toUpperCase();

  let comparison = 0;
  if (Device_TypeA > Device_TypeB) {
    comparison = 1;
  } else if (Device_TypeA < Device_TypeB) {
    comparison = -1;
  }
  return comparison;
}

komps.sort(compare);

//node.warn(arr)
msg.payload = komps

msg.topic = k

return msg;

```

The table in the template node looks like this:

```auto
<script>
var grundpfad = "teststuff"
</script>

<table id="table" border="1">
     <tr>
        <th style="width: 10%;" >Gerätename</th> 
        <th style="width: 10%;" >Laufende Nummer</th>
        <th style="width: 10%;" >Seriennummer</th>
        <th style="width: 5%;" >Typ</th>
        <th style="width: 5%;" >Buchungsdatum</th>
        <th style="width: 16%;" >Remark</th>
        <th style="width: 6%;" >Ort</th>
        <th style="width: 60%;" >Medium1</th> 
        <th style="width: 20%;" >Medium2</th>
        <th style="width: 20%;" >Medium3</th>
 </tr>
 <tbody>
 <tr ng-repeat="row in msg.payload">
   <td ng-repeat="item in row" >{{item}}</td>
 </tr>
 </tbody>
</table>

```

What i dont get is a working Link for Pics or PDFs for the Browser to open, or a way to display the media in the table.

I am not good in html, perhaps somebody may help ?

Greetings  
Chorum

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [18 December 2020 14:15 UTC](https://discourse.nodered.org/t/link-to-media-in-template-node-html/37693/2 "2020-12-18T14:15:48Z")

</div>

After working some more time on it, i found out that the security of the Browser wont let me translate html links to a filesystem link to open the file.

The best what i get is rightklick - oben in new tab - enter the link in the new tab.

If somebody has knowlege about that, please feel free to share 🙂

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 December 2020 14:39 UTC](https://discourse.nodered.org/t/link-to-media-in-template-node-html/37693/3 "2020-12-18T14:39:03Z")

</div>

If you put the files in a folder under .node-red, say `static` for example, and in settings.js you put something like  
`httpStatic: '/home/thenodereduser/.node-red/static/',`  
then you will be able to access them through node-red using `http://ip:1880/filename

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [18 December 2020 15:45 UTC](https://discourse.nodered.org/t/link-to-media-in-template-node-html/37693/4 "2020-12-18T15:45:03Z")

</div>

Its our company Network and i want to use files and folders in our network.

May be node red could be setup in an other way to reach this.  
Perhaps i get new ideas or find something else.  
But i hope for some good ideas in the Node Red Forum.  
Here I found very good help 🙂

Greetings  
Chorum

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 December 2020 16:05 UTC](https://discourse.nodered.org/t/link-to-media-in-template-node-html/37693/5 "2020-12-18T16:05:00Z")

</div>

I think your company IT department might not like the idea of being able to open random files around the network in a browser. I think there are potential security issues there, but I may be wrong.

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [19 December 2020 00:38 UTC](https://discourse.nodered.org/t/link-to-media-in-template-node-html/37693/6 "2020-12-19T00:38:25Z")

</div>

I need to put that on hold until next year. Vacation...  
I will talk with the Head of our IT early January. The usage would be only internally, and the files are reachable internally for the employees i try to make it for. so no trouble i think.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 January 2021 00:38 UTC](https://discourse.nodered.org/t/link-to-media-in-template-node-html/37693/7 "2021-01-18T00:38:36Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
