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

script request for picture to be posted in chat, from an internet source

Is what I asked for in the title of this topic possible? I would like a script that would post a picture from an internet source such as: <a href="http://4.bp.blogspot.com/-ohqlppNJIHo/UBGGVo9rTcI/" rel="nofollow">http://4.bp.blogspot.com/-ohqlppNJIHo/UBGGVo9rTcI/</a>... to the chat window. Thank you!
1433698443

Edited 1433698545
Gen Kitty
Forum Champion
You're in luck, I have just that! (Passed to me from The Aaron) Make a macro like such: !pic-bare ?{URL} And here is the script. on('ready', function() { on('chat:message', function(msg) { 'use strict'; var fPart, tPic = '', Pic, piclink; if (msg.type == "api" && playerIsGM(msg.playerid) && msg.content.indexOf("!pic") !== -1) { piclink = msg.content.split(' ')[1]; fPart = "&lt;div style='box-shadow: 3px 3px 2px #888888; font-family: Verdana; text-shadow: 2px 2px #000; text-align: center; vertical-align: middle; padding: 1px 1px; margin-top: 0.1em; border: 1px solid #000; border-radius: 8px 8px 8px 8px; color: #FFFFFF;" if(msg.content.indexOf("!pic-bare") === -1) { tPic = fPart + "background-color:#666666;'&gt;● " + msg.who + " Shared a pic: ●&lt;/div&gt;"; } Pic = fPart + "background-color:#AAAAAA;'&gt;&lt;img src='" + piclink + "'&gt;&lt;/div&gt;"; sendChat('', "/direct " + tPic + Pic); }; }); });
Thank you GenKitty!!!
I'm getting an "Unexpected Identifier" when I save the script...
1433700760
Gen Kitty
Forum Champion
Alas, I didn't write it and have no idea how to troubleshoot it. I suspect it may be an issue with the copy-paste process, since this is such a simple script. Hopefully The Aaron, or someone else, will be by to offer more help beyond "Try saving the script again"
1433702947

Edited 1433702965
Lithl
Pro
Sheet Author
API Scripter
You don't need a script for this, not any more. [My Alt Text](?{URL}) The alt text can be anything, and only really matters for someone using for example a screen reader (say, if they're blind). If the URL doesn't end in .jpg, .jpeg, .gif, or .png it will be rendered as a link (with the text "My Alt Text"). In order to force the parser to make an image out of something that doesn't end with an image extension, you can use a page anchor to trick the parser: [My Alt Text](?{URL}#.png) The Markdown parser sees that it's ending in .png, so it renders as an image, and then the browser ignores everything after the # when resolving the address for the image.
1433706242
The Aaron
Pro
API Scripter
I didn't actually write that script, I think William gave it to me. He didn't write it either. No idea who wrote it. It probably is a "copy-pasta" issue. Can check when I get home. Brian is right though, no script required. The nice thing about the script is the formatting, but being able to do it in markdown is great. One note about the #fragment bit, you can use anything the browser considers an image, so things like SVGs or animated gifs work fine, just be aware that animated gifs in the chat can seriously bog down less powerful computers.
Sorry for being an idiot, but.... If I want the macro to simply post an image, without asking me what image to post, I use what again, for example for this Trex located at <a href="https://s-media-cache-ak0.pinimg.com/736x/6c/66/c9" rel="nofollow">https://s-media-cache-ak0.pinimg.com/736x/6c/66/c9</a>... Thanks for your patience... I kept getting it asking me for what image to post.... =)
1433710289
Lithl
Pro
Sheet Author
API Scripter
If you just want a macro that always posts the same image, just replace the ?{URL} bit with the image's url.
Someone must have a link to the !pic script in the repository fir him, yeah?
1433770602
The Aaron
Pro
API Scripter
Here's a gist of it: <a href="https://gist.github.com/shdwjk/fbe81845adb2b7a71333" rel="nofollow">https://gist.github.com/shdwjk/fbe81845adb2b7a71333</a>
I cheat. Once the markdown method became available I went and created an Imgur account and uploaded all of my monster pictures, symbols, etc, to it. I leave a browser open on Imgur during sessions and if I need something I just click on the photo, it gives me the markdown, and I copy and paste it into the chat window with whatever verbiage I desire. With this method I was able to scrub several megabytes of graphics out of my account and now have an easy way to access them on the fly. The script opens up the possibilities like having frequently used graphics on a menu system: like combining token-mod with throwing a graphic of the condition into the chat window
Thank you for uploading the !pic script to the repository, Aaron.
1433811680
The Aaron
Pro
API Scripter
Well, it's technically not in the repository, but it is online somewhere... I'm not sure I'd feel comfortable uploading someone else's script to the official repo.
1433847620

Edited 1433847692
I remember that script, he uploaded it as a snipnet to share. His name escapes me however. Might be a different person though: on("chat:message", function (msg) { var cmdName = "!pic "; var msgTxt = msg.content; var msgWho = msg.who; var piclink = msgTxt.slice(cmdName.length); if (msg.type == "api" && msgTxt.indexOf(cmdName) !== -1) { log(piclink); sendChat(msgWho, '/direct &lt;b&gt;&lt;u&gt;shared:&lt;img src="' + piclink + '"&gt;'); }; });