What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

We've already got it for questions and answers. Let's get it for chat too! Most of my images come from screen captures so this would be really great!

Uploader via Question/Answer

Uploader via Chat

share|improve this question
14  
This is definitely on our list of things to do; we were mainly waiting on the code to stabilize before integrating it –  Marc Gravell Mar 25 '13 at 16:34
1  
Great to hear. I look forward to it! –  SpartanDonut Mar 25 '13 at 16:58
    
Have some rep, Todders. –  Almo May 11 '13 at 18:39
    
@MarcGravell any update on this? I'm just curious / anxiously waiting :) –  SpartanDonut Aug 5 '13 at 16:07
    
@Todders did that not get done? Hmm... That's odd - will look into why... I thought we had them up to date with each other. –  Marc Gravell Aug 5 '13 at 17:22
    
@MarcGravell Not that I can tell. I look forward to hearing what you find out! –  SpartanDonut Aug 5 '13 at 17:59
3  
@ToddersLegrande Now now, you don't reasonably expect something as complex as a picture upload script to become stable in a TINY little year do you??!?! –  MickLH Feb 25 at 19:26
    
@MarcGravell Mick makes a good point. No rush on this. Sorry for being so impatient. –  SpartanDonut Feb 25 at 19:29
    
@MarcGravell Any update? This's integrated into the main site, but not chat. I find it a pain to save it to the desktop and then browse through all of my files and folders with the upload dialog to add an image in chat. As a moderator, this would be greatly appreciated. –  Annonomus Penguin Apr 4 at 21:39
2  
Can we either get an ETA or a status as why this hasn't been done yet? It sounded like it was planned to be implemented but hasn't been. I hate to nag but I feel plenty of time has passed for me to question this again. Thank you! –  SpartanDonut Jun 19 at 20:24

2 Answers 2

Well for the time being I've signed up for the imgur api and created a tampermonkey / userscript for this. My code is included below.

If you use this make sure you update the URL you want to use this on as well as your own API key.

Once you have this running on the chat room you wish to use it in it is simply a matter of clicking in the text box and pasting in image data. This script probably has flaws due to the fact that I just put it together based on several blogs and being a complete newbie to how userscripts work, etc. but it fits my needs for now.

// ==UserScript==
// @name       tehimgur
// @namespace  http://chat.stackexchange.com/rooms/19/game-development
// @version    0.1
// @match      http://chat.stackexchange.com/rooms/19/game-development
// ==/UserScript==
function upload(file) {
    if (!file || !file.type.match(/image.*/)) return;

    document.body.className = "uploading";
        var text = document.getElementById("input").value
        document.getElementById("input").value = "Uploading...";
    var fd = new FormData();
    fd.append("image", file);
    var xhr = new XMLHttpRequest();
    xhr.open("POST", "https://api.imgur.com/3/upload.json");
    xhr.onload = function () {
        var link = JSON.parse(xhr.responseText).data.link;
            document.getElementById("input").value = text + link;
    }
    xhr.setRequestHeader('Authorization', 'Client-ID YOUR-CLIENT-ID-HERE');
    xhr.send(fd);
}

/* Handle paste events */
function pasteHandler(e) {
    if (e.clipboardData) {
        var items = e.clipboardData.items;
        if (items) {
            for (var i = 0; i < items.length; i++) {
                if (items[i].type.indexOf("image") !== -1) {
                    var blob = items[i].getAsFile();
                    upload(blob);
                }
            }
        }
    }
}

document.getElementById("input").addEventListener("paste", pasteHandler);
share|improve this answer
    
Additionally, make sure your redirect URL is set to imgur.com (https) in your imgur app settings –  SpartanDonut Dec 12 at 17:38

Can we do this without a dialog and a button ... just have the chat window accept image file drops or something ... would be much cooler :)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .