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.
- Navigate to the Library folder in your Home directory and from there go to the Widgets directory (~/Library/Widgets).
- If you have the widget installed you should see a file named "Image Upload". Right-click on this file and choose "Show Package Contents"
- The folder that opens contains the file imageupload.js which is the one we want to edit.
- In your text editor of choice navigate to line 287, it should begin with "output = "
- Comment that line out by placing "//" at the beginning and then insert a new line directly below it.
- In the new line paste the following text:
- Save the file and you are done.
- "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;"
Share
Categories
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
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? :)
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 :)
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
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 Permalink rate up rate down ReplyTinyURL 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
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 Permalink rate up rate down ReplyWow, 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/
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:-/
Cant upload webloc's with h4xr either!
Only url's dragged directly from location field. Silly strange.
For some reason png-upload now works with h4xr!
December 30 2008 at 6:45 AM Report abuse Permalink rate up rate down ReplyI 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 Permalink rate up rate down ReplyI 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 Permalink rate up rate down ReplyCorners more rounded and no prefs!
December 29 2008 at 1:46 PM Report abuse Permalink rate up rate down ReplyHow 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 Permalink rate up rate down ReplyTo 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!
Hot Apps on TUAW
Deals of the Day
more deals- Refurb Apple MacBook Air Laptops: 12" 64GB SSD for $699 + free shipping
- JVC Motion Sensing Clock Radio with Dual iPod Docks for $55 + free shipping
- Apple iPhone Headset with Mic for $4 + $2 s&h
- miFrame Picture Frame Dock for iPad for $64 + $8 s&h
- Refurb Apple iPod nano 8GB MP3 Player for $99 + free shipping, 16GB for $119
- Hannspree Apple-Shaped 28" 1080p LCD HDTV for $270 + free shipping
Software Updates
more updates- EFI Firmware Update brings Lion Internet Recovery to 2010-model Macs
- OS X Lion 10.7.3 released with Safari 5.1.3, Wi-Fi bug fix
- Aperture updated to 3.2.2, addresses Photo Stream issue
- Apple updates Keynote to address Lion issues
- Google Search app gets new look on iPad
- Apple releases Apple TV Software Update 4.4.3



28 Comments