Skip to Content

Fixing the Image Upload widget

The Image Upload widget featured here is a freeware widget by Model Concept which allows you to upload an image to ImageShack simply by dropping it onto the widget. The result is that the URL is auto-magically saved to your clipboard. The overall experience is pretty slick; it supports audio and Growl notifications as well as URL shortening with help from TinyURL ... at least it used to. Read on for my journey from widget woes to uploading bliss.

At some point several months ago, dropping an image onto the widget resulted in a never-ending spinner of terror that teased the user with hope that someday the image would be uploaded. This saddened me greatly as I used this widget on a near-daily basis for Tweeting images as well as the occasional post to my blog. My only real "work around" was to get an Image Shack account and actually upload images through the site. Not fun.

Recently, I became tired of uploading images manually and then hopping over to an URL-shortener to make the image Tweetable. I did some digging and after finding nobody else that was as distraught as I about not being able to use my favorite widget, I decided to give Image Shack's image uploading widget a try. Unfortunately, the results were less than stellar. There was no option to shorten the URL and the text that was copied to the clipboard had "-n " prepended to the beginning of the URL! This was a struggle because I couldn't just copy the output I had to actually format the output before it was even usable.

And this is what brings us to today. Rather than taking "-n " for an answer, I figured I would get my hands dirty. In Image Shack's widget I found a stray "-n" flag for an echo call which is what was fudging my output. Success! Given how easy it was to fix the Image Shack widget I decided to poke around in the Image Upload widget to try and figure out what was holding up the widget during the upload.

What I found was a method "widget.system()" that was used to run Terminal commands within a widget. Image Upload was using this method to send the image's address to TinyURL prior to copying it to the clipboard. Well, as it turns out the command was hanging due to changes in the format of the HTML that is output from TinyURL. After fixing the command in the widget.system() method and saving the updated imageupload.js file I restarted Dashboard to test and everything worked wonderfully!

I do not want to distribute anyone else's code so instead I will tell you the steps to fix the widget on your own! Besides, learning is fun and hopefully this will be a good experience.
  1. Navigate to the Library folder in your Home directory and from there go to the Widgets directory (~/Library/Widgets).
  2. If you have the widget installed you should see a file named "Image Upload". Right-click on this file and choose "Show Package Contents"
  3. The folder that opens contains the file imageupload.js which is the one we want to edit.
  4. In your text editor of choice navigate to line 287, it should begin with "output = "
  5. Comment that line out by placing "//" at the beginning and then insert a new line directly below it.
  6. In the new line paste the following text:
    1. "output = widget.system( "/usr/bin/curl -s \"http://tinyurl.com/create.php?url=" + str_ImgURL + "\" | /usr/bin/awk -F\\\" \'{ print $2 }\' | /usr/bin/grep http | /usr/bin/awk \'NR==12{print $1}\'", null ).outputString;"
  7. Save the file and you are done.
Now all you have to do is re-add the widget to your Dashboard and you will be in easy image uploading bliss. I have already contacted the creators of the widget in hopes that they will release an update that includes this fix; in the interim this works perfectly. Feel free to drop Model Concept a note if you'd like them to release an update as well.

Categories

Internet Tools

The Image Upload widget featured here is a freeware widget by Model Concept which allows you to upload an image to ImageShack simply by...
 

Add a Comment

*0 / 3000 Character Maximum

28 Comments

Filter by:
nim.rose

I fixed Image Shack's ImageUploader widget. It won't utilize TinyURL or play Audio like this one does (which I prefer over Image Shack's widget), but at least I got rid of the annoying "-n" at the beginning of the copied link.

Follow the Blog Author's instructions for navigating to your Widget folder (~/Library/Widgets). Again, follow the instructions to "Show Package Contents" of the iShack.wdgt. Open up the iShack.js file with TextEditor (or any text editing app as stated in the original Blog).

There are only 2 instances of a "-n". In TextEditor, I used the Find command (⌘F) and typed in "-n" (without the quoations). Do this a second time and you will find this line:

widget.system('echo -n '' + copytext + '' | pbcopy', null);

Simply delete the "-n" after "'echo" and save the file.

The line should now look like this:

widget.system('echo '' + copytext + '' | pbcopy', null);


Reload the widget onto your dashboard and it should now copy the link without that stray "-n".

Personally, I am only going to use this until the Image Uploader widget is fixed again as that has audio confirmation as well as Growl integration, not to mention TinyURL support. What more can you ask for? :)

February 26 2009 at 6:41 PM Report abuse rate up rate down Reply
nim.rose

It broke again!

February 26 2009 at 6:21 PM Report abuse rate up rate down Reply
Tom Stoelwinder

Hi there, I'm the dev of the Image Upload widget.

Thanks a lot for going ahead and posting these instructions out for everyone to use to patch up the widget! I've gone ahead and updated the download on my server to include the fix.

Grab it at http://www.stoely.com/goodies/image-upload-widget.zip

Glad to see you all like the widget, sorry it broke for a while :)

January 05 2009 at 2:55 AM Report abuse rate up rate down Reply
now4real954

Aron you always have great articles and lots of comments for your articles...good choice TUAW for the new hire...

hope they stay this great

January 01 2009 at 5:51 PM Report abuse rate up rate down Reply
jon

I'm a big fan of the image shack widget and like you, the -n was driving me crazy but couldn't find anything on the web to help fix it. This article pointed me in the right direction and I removed that stray -n. Thanks!

December 30 2008 at 8:15 PM Report abuse rate up rate down Reply
dbr

TinyURL does actually have an API. It's used the same way, but you use /api-create.php?url=... instead of /create.php?url..

That means you can change line 287 (the output = widget.system("/usr/bin/curl http://tinyurl.com" one) to...

output = widget.system( "/usr/bin/curl -s "http://tinyurl.com/api-create.php?url=" + str_ImgURL + """, null ).outputString;

..and it will be much more reliable over time too (as it wont break when TinyURL change their HTML)..

Fixed widget:
http://static.dbrweb.co.uk/code/osx/Image_Upload_fixed30dec2008.zip

December 29 2008 at 9:55 PM Report abuse rate up rate down Reply
Matthew Heidenreich

or you can just use Quickshareit, which allows you to drag your file onto the icon in your doc and it will upload and give you a link. They finally came out with an update to stop it from crashing so its pretty slick

December 29 2008 at 2:48 PM Report abuse rate up rate down Reply
1 reply to Matthew Heidenreich's comment
Nuno Sousa

Wow, that looks really good!

As long as we're listing these kinds of apps, there's also Dragster from Ambrosia soft. (but it's more for your private FTP,SFTP,DAV,etc servers)
http://www.ambrosiasw.com/utilities/dragster/

December 29 2008 at 3:34 PM Report abuse rate up rate down Reply
Olligarski

Image Upload will not do png's and I can't get h4xr to do it either!

Tried uploading the new IU with h4xr but no go on that as well:-/

December 29 2008 at 1:48 PM Report abuse rate up rate down Reply
2 replies to Olligarski's comment
Olligarski

Cant upload webloc's with h4xr either!

Only url's dragged directly from location field. Silly strange.

December 29 2008 at 2:07 PM Report abuse rate up rate down Reply
Olligarski

For some reason png-upload now works with h4xr!

December 30 2008 at 6:45 AM Report abuse rate up rate down Reply
Nuno Sousa

I like h4xr (http://h4xr.org/). It allows you to upload any file type (sort of like rapidshare) but it uses the same widget. Very handy

December 29 2008 at 11:55 AM Report abuse rate up rate down Reply
2 replies to Nuno Sousa's comment
PowerLlama

I second h4xr. Great widget, that I think has the same look as this one. Like the exact same.

December 29 2008 at 1:11 PM Report abuse rate up rate down Reply
Olligarski

Corners more rounded and no prefs!

December 29 2008 at 1:46 PM Report abuse rate up rate down Reply
Max

How is this widget supposed to work? I installed the updated widget. Select an image on my desktop, activate Dashboard. I am unable to drag my image into the widget, or drag my image at all. Am I missing something?

December 29 2008 at 11:49 AM Report abuse rate up rate down Reply
1 reply to Max's comment
Aron Trimble

To use the widget select the image you want to upload in Finder (click and hold on the file's icon). Then activate Dashboard (still holding the mouse button down) and drag the image on top of the widget. When you see the dashes crawling around on the widget you are ready to drop the file onto the widget (let go of the mouse button).

Hope this helps!

December 29 2008 at 11:58 AM Report abuse rate up rate down Reply
Buy an ad here

Hot Apps on TUAW

Tweets

© 2012 AOL Inc. All Rights Reserved.