- Issue created by @Anybody
- π©πͺGermany Anybody Porta Westfalica
Especially for SVG images it would be helpful, as they are currently inline and the browser does not allow downloading it easily.
- π©πͺGermany Anybody Porta Westfalica
Here are some ways how an inline SVG could be converted into a download using JavaScript:
https://stackoverflow.com/questions/43804171/how-to-extract-svg-as-file-...
https://www.beaubus.com/blog/how_to_save_inline_svg_as_png_with_vanilla_...Another alternative would be to provide the download server-side, similar to the PNG?
- πΊπΈUnited States tr Cascadia
If you like the idea, we'd be happy to provide a MR for the various outputs.
Yes, I would absolutely like to have this feature and would be happy to work with you to get it into this module in a way that is useful.
If you take a look at
drush help barcodes:generate
, you will see that there is a --binary output option for the PNG format. It would be easy enough to add an option to link the barcode to a binary image download, in the PNG output format, regardless of which format was chosen for the web display. So you could use the SVG inline format for web pages but return a binary PNG from the link.It would also be easy enough to add a REST resource to return a barcode in any of the supported formats. I actually did this once on my test site just for debugging purposes.
The source code for this module's drush command is useful as an example if you want to implement either the link or the REST resource.
Supporting binary download in a format other than PNG would take a little more doing. The PNG binary format is supported by the underlying tecnickcom/tc-lib-barcode library, but no other binary format is directly supported.
- π©πͺGermany Anybody Porta Westfalica
@tr thanks! I'll add it to our roadmap.
For the .png it might be even easier, using the HTML5 download attribute for links:<a href="x.png" download>Download</a>
I didn't try it for images yet, but I think it might work!
The svg might be the hardest part, but I think it's important to also support that to have it as a real .svg for download to print and edit as-is.