all 19 comments

[–]wizzwizz4[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (0 children)

Huh. When an SVG-with-JavaScript is included in an img tag, the JavaScript doesn't run.

[–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (17 children)

Yeah we can't render svg here without stripping js, especially these days.

[–]wizzwizz4[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (16 children)

In <img / > tags Firefox ignores the JavaScript. Is that the same in Chrome? You can use my example to test. (Don't worry; it doesn't mine crypto or use Meltdown to GET U.)

Otherwise, you can just display the image in an <iframe></iframe>.

[–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (15 children)

Oh, iframe is a good idea. Yeah the js runs for me in Chrome once I leave the site and view it.

[–]wizzwizz4[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (14 children)

That's expected. But does it run in Chrome in an <img /> tag? I tested it and it didn't, so there should be no problem with including SVGs.

[–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (13 children)

It looks like you're right, no internal js is run if rendered as an <img>

[–]wizzwizz4[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (12 children)

So, add? (Please please please?) 🥺

[–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (11 children)

Alright, it's on our Todo list. I'll show you where the relevant code is if you're so inclined.

[–]wizzwizz4[S] 3 insightful - 1 fun3 insightful - 0 fun4 insightful - 1 fun -  (10 children)

That'd be great; I can't actually find it right now (assuming it's Python).

Edit: https://github.com/libertysoft3/saidit/blob/master/r2/r2/public/static/js/expando-md.js

Edit #2: https://github.com/libertysoft3/saidit/pull/9

[–][deleted] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (1 child)

Nice work! Supporting more url formats was a boss change too. I'll get around to adding this same image support for saidit posts proper too.

/u/magnora7 check it out the wizz added .svg support.

https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/mudflap.svg

https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/json.svg

You can embed rasters in vectors? Hmm..

https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/image.svg

[–]magnora7 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (0 children)

Wow that's great! I love it when other users contribute code and add more functionality. I thanked them for it, that's awesome

[–]magnora7 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (7 children)

Hey nice coding wizzwizz, solid job! Very much appreciate the added functionality, and I'm sure the users will too. Thank you. We're proud to have more code contributions to the site by users like you.

[–]wizzwizz4[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (6 children)

Adding your wishlist to GitHub Issues, and maybe setting up a Project Board or two would help to permit contributions.