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="http://www.barcodes4.me/barcode/qr/myfilename.png?value=My%20QR%20Code">

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

<img src="http://www.barcodes4.me/barcode/qr/myfilename.png?value=" + {{ 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:

<script>
var barcode_url="http://www.barcodes4.me/barcode/qr/myfilename.png?value=" + {{ doc.naming_series }}
</script>

then in the body:

<img src=barcode_url>

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

https://mcleans.frappecloud.com/barcode_url

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?

Thanks.