Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×

Dynamic Image Source

1672493414

Edited 1672493436
Hi, I was wondering if the dynamic image source mentioned here works? <a href="https://wiki.roll20.net/Image_use_in_character_sheets#Dynamic_Image_Source" rel="nofollow">https://wiki.roll20.net/Image_use_in_character_sheets#Dynamic_Image_Source</a> I am using that basic example, but I can't seem to get it to work. Anybody able to provide a working example or something like that?
1672525285

Edited 1672525348
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It definitely works. I've used it in one published sheet and one in progress sheet. Something to check is, are you using legacy sanitization? I'm not entirely sure it would work with that. The example code on the wiki should work for you. Can you share the code your are using to try? Maybe there's a copy paste error or other issue?
I used exactly as what was in that link: &lt;script type="text/worker"&gt; on("clicked:img", function() { setAttrs({sheet_image:"<a href="https://s3.amazonaws.com/files.d20.io/images/320059219/FLNHRsaNtlRToxtQCom-1Q/original.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/320059219/FLNHRsaNtlRToxtQCom-1Q/original.png</a>"}); }); &lt;/script&gt; &lt;main&gt; &lt;button type="action" name="act_img"&gt;Image&lt;/button&gt; &lt;input type=”text” name=”attr_sheet_image”&gt; &lt;img name=”attr_sheet_image”&gt; &lt;/main&gt; Could you perhaps tell me in which published sheet you have used it so perhaps I could look there and take an example? Or maybe you can see what I did wrong? Thanks for your reply!
1672528449

Edited 1672528905
GiGs
Pro
Sheet Author
API Scripter
Does it work if you change &lt;main&gt; and &lt;/main&gt; to &lt;div&gt; ? I seem to remember &lt;main&gt; is one of the restricted names you shouldn't use (but it's late and I may be misremembering). Also, possibly worth a try changing the button name from act_img to act_image. img is the name of your html element, and it shouldn't happen, but there may be an error on roll20's side there.
1672528710

Edited 1672529311
Oosh
Sheet Author
API Scripter
It's the quotes - whoever put that example up on the wiki has used the wrong symbol for the HTML attributes. Change them to regular " quotes (like in the &lt;button&gt; element) and it should work. Edit - fixed the wiki page for the next person who does a copy paste
1672528881
GiGs
Pro
Sheet Author
API Scripter
Oh yes, well spotted - always avoid curly quotes when programming.
1672530490
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
GiGs said: Does it work if you change &lt;main&gt; and &lt;/main&gt; to &lt;div&gt; ? I seem to remember &lt;main&gt; is one of the restricted names you shouldn't use (but it's late and I may be misremembering). This would only happen if you were using legacy sanitization.
That fixed it, thank you all for the help!