/** * Share an image to all players when you have an image URL * Author: @Krishmero#1792 */ let imagePopup = (imageUrl) => { // Display the image popout and share it. const ip = new ImagePopout(imageUrl); ip.render(true); ip.shareImage(); }; let chatDialog = (imageUrl) => { ChatMessage.create({ user: game.user._id, content: ``, type: CONST.CHAT_MESSAGE_TYPES.OOC }); }; let selectOptions = game.user.isGM ? `

` : ''; new Dialog({ title: `Share Image via URL`, content: ` <form> ${selectOptions}
<input type="text" id="image-url" name="image-url" />
</form> `, buttons: { yes: { icon: "", label: `Share`, callback: (html) => { let imageUrl = html.find('#image-url').val(); let permission = html.find('select#output-options')[0]?.value || null; if (!imageUrl) { return ui.notifications.info("You did not provide a valid image."); } if (game.user.isGM && ['popup', 'both'].includes(permission)) { imagePopup(imageUrl); } if (!game.user.isGM || ['chat', 'both'].includes(permission)) { chatDialog(imageUrl); } } }, no: { icon: "", label: `Cancel` }, }, default: "yes" }).render(true)