Uncharted Design

Daily Photos

Currently...

Fixing the Twitpic Badge

A modified version of this trick to get badges to run after the page loads. A bit hacky, but it works wonders.

We need to specify a place for the code to be injected. This div is what twitpic’s java looks for, and will be where your badge is written.

<div id="twitpic_badge_container_v1" style="border: 1px solid rgb(255, 255, 255); padding: 15px; background-color: rgb(255, 255, 255);"></div>

Now at the footer of your page, we put in this script to stop twitpic from writing wherever it is placed.

<script language="javascript"><!--
var old_document_write = document.write;
var twitpic_badge_data = "";
document.write = function(s) {
twitpic_badge_data += s;
}
// --></script>

After, put in your whatever code is given to you by the twitpic badge generator. In our case it looks like this:

<script type="text/javascript" src="http://twitpic.com/badge/v1.jsx?username=uncharteddesign"></script>

Follow with the end script to make document.write function as normal.

<script language="javascript"><!--
document.write = old_document_write;
// --></script>

You should be able to grab and go from that. If you would like more explanation, just let me know.

You also might enjoy…

Tags: ,

  • Ethan (below) is correct.
    Unfortunately Twitpic has done away with their badge.
    I am wondering if you know how to 'create' a badge, utilizing the rss feed of the images for twitpics??
    I really liked the idea of the writing I could add to each photo, using the subject line in a mobile upload, and it would show up on my site too.
    Flickr doesn't have that feature.
  • ethan
    Twitpic badge generator doesn't seem to exist anymore...
  • Dave
    Thank-you! This fixed the problem perfectly for me and brought my page load back to normal. Without this, I would have removed the Twitpic badge. Great work.
  • Thanks, and good to know! I think the big problem is that the current script has to process before the rest of the page will load. Even if the hardware gets upgraded, it could still pose a problem.
    I know that twitter’s end result setup is similar to what I’ve done here, maybe it’s something twitpic will look at?
  • Great tutorial. Twitpic is moving to a new hardware platform when we launch the new version of the site and the load time shouldn't be an issue anymore and we will be able to scale easier if it does become an issue again. Love the ingenuity of this hack though :)
  • Noah,

    Can you help please??

    Ethan (above) is correct.
    Unfortunately Twitpic has done away with their badge.
    I am wondering if you know how to 'create' a badge, utilizing the rss feed of the images for twitpics??
    I really liked the idea of the writing I could add to each photo, using the subject line in a mobile upload, and it would show up on my site too.
    Flickr doesn't have that feature.
blog comments powered by Disqus