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 .
×
Create a free account

img tag and variables?

1622795399
Senjak
Pro
Sheet Author
I was hoping that someone could point me in the right direction. I was looking at a character sheet that uses a number of images all over the html. That makes it difficult to make changes to as every addition or deletion of some of the images needs to duplicated in many places. I thought, hey, how about something like: &lt;input type="hidden" name="attr_pc20" value="<a href="https://s3.amazonaws.com/files.d20.io/images/225360056/Wu005gs7zndi9Qq99A_FyQ/max.png?1622302533" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/225360056/Wu005gs7zndi9Qq99A_FyQ/max.png?1622302533</a>"&gt; &lt;input type="hidden" name="attr_pc21" value="<a href="https://s3.amazonaws.com/files.d20.io/images/225360083/GRaBYmknz450u7YR7B3sTw/max.png?1622302542" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/225360083/GRaBYmknz450u7YR7B3sTw/max.png?1622302542</a>"&gt; at the top of the code followed by something like: &lt;img class="pretty-picture" src="pc20" alt="earth" /&gt; &lt;img class="pretty-picture" src="pc21" alt="moon" /&gt; further down and everywhere where the the images are used. Sadly I tried a number of different syntax and didn't have any luck.Googled around a bit and also didn't have any luck. Can someone share an example of how to do this please? Thanks! Senjak
1622803853
GiGs
Pro
Sheet Author
API Scripter
It sounds like what you need is CSS. I'm not sure why you have an input with an image, what exactly are you trying to do? You can do something like this: &lt;div class="pretty-picture-20" /&gt; And then in your css div.pretty-picture-20 { background-image : url(" <a href="https://s3.amazonaws.com/files.d20.io/images/225360056/Wu005gs7zndi9Qq99A_FyQ/max.png?1622302533" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/225360056/Wu005gs7zndi9Qq99A_FyQ/max.png?1622302533</a>") ; } You cant use CSS to set the source of an img tag, which is why I changed it to a div container here. You might need to set the divs dimensions, but this gives you a starting point to explore.
1622804990
Andreas J.
Forum Champion
Sheet Author
Translator
<a href="https://wiki.roll20.net/BCS/Images" rel="nofollow">https://wiki.roll20.net/BCS/Images</a> has more examples on how to do images on char sheets
1622811412
Senjak
Pro
Sheet Author
Thank you! I'm trying to set a variable with the url of the image to simplify the character sheet's code that I was looking at. Right now they use a small number of images all over the place and any changes require every one of the locations to be updated correctly.&nbsp; So I'm hoping to set the image location in one place and then just use the reference everywhere else. I may have picked the wrong syntax to set a variable that I could use in the way I've intended! Thanks! Senjak GiGs said: It sounds like what you need is CSS. I'm not sure why you have an input with an image, what exactly are you trying to do? You can do something like this: &lt;div class="pretty-picture-20" /&gt; And then in your css div.pretty-picture-20 { background-image : url(" <a href="https://s3.amazonaws.com/files.d20.io/images/225360056/Wu005gs7zndi9Qq99A_FyQ/max.png?1622302533" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/225360056/Wu005gs7zndi9Qq99A_FyQ/max.png?1622302533</a>") ; } You cant use CSS to set the source of an img tag, which is why I changed it to a div container here. You might need to set the divs dimensions, but this gives you a starting point to explore.
1622811434
Senjak
Pro
Sheet Author
Thank you! Senjak Andreas J. said: <a href="https://wiki.roll20.net/BCS/Images" rel="nofollow">https://wiki.roll20.net/BCS/Images</a> has more examples on how to do images on char sheets