Include Sales Order field in an <img src> tag on Custom Report

I’ve found an API that will allow me to insert a barcode on a custom print format. Using barcodes4me’s API I can call such an image file into the report using:

<img src="">

However my statement for the URL needs to include the sales order naming series field value in it. So I simply tried:

<img src="" + {{ doc.naming_series }} + ">"

but that doesn’t work - obviously, because HTML is not a programming language.

So I thought I could write a script to create the url then call the url within the body:

var barcode_url="" + {{ doc.naming_series }}

then in the body:

<img src=barcode_url>

But that results in a broken image link icon with a path of:

So my script either isn’t executing or is it because it’s executing client side that it fails?

If I wanted to write the same function in PHP what would it be and should that then work?