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

Change Map - Clone Tokens Help

I'm trying to use this API script. It only moves one of the characters and gives me this error on the others: "ERROR: Please use the 'thumb' size for imgsrc properties.". I created the sheets the same way and made and uploaded the tokens to my library. Does anyone have any ideas? Thanks
I think I found the issue. The error is coming from this line of code. &nbsp; &nbsp; &nbsp; &nbsp;var imgsrc = token.get("imgsrc").replace("max","thumb"); It is working with three of the tokens that have a starting URL like&nbsp; "<a href="" rel="nofollow"></a>" and outputs the following URL which works "<a href="" rel="nofollow"></a>" The two that cause the error have a URL that looks like this: "<a href="" rel="nofollow"></a>" so "med" is not being replaced.&nbsp; So I modified the code as follows and it now works: &nbsp;var imgsrc = token.get("imgsrc").replace("max","thumb"); if (imgsrc.indexOf("max") &gt; 0) { var imgsrc = token.get("imgsrc").replace("max","thumb"); } &nbsp; &nbsp; else if (imgsrc.indexOf("med") &gt; 0){ var imgsrc = token.get("imgsrc").replace("med","thumb"); } My questions are where do the "max" and "med" come from? Is this the correct approach or just a quick hack? New to roll 20 but have over 40 years in the computer industry, but just starting to learn the API. Thanks for any help.
Forum Champion
Marketplace Creator
API Scripter
max, med and thumb are generated by Roll20 to have more efficiently delivered graphics at various zoom levels and resolutions. It is possible however, that the issue is related to the restriction upon the API that it cannot access items from the marketplace, only the user's art library. Do any of the tokens you are trying to move have images or default token images that come from a marketplace item? If this is the case, and the script works with other tokens, the quickest fix would be to download the token image (right click-save to disk), and upload a copy into your own library and use that.
No, I uploaded them all. I have the script working now, as the issue was two were tagged with "med". The fix doesn't seem to affect anything other than it now works.