You Shot My Banjo

Added on April 19th, 2012

I was initially going to add a few more games and a lot more screenshots before writing about You Shot My Banjo on my blog, but now that my gaming PC has decided that it doesn’t want to play along anymore and wants to crash every hour or so, I’ll just fast track this post.

What exactly is You Shot My Banjo? It’s a project, a website, that was born out my need to offload all the game screenshots I take while playing. As it was they were just collecting dust on my HD. Not only that, but I wanted to create a proper project with CodeIgniter and Twitter Bootstrap (both of which are rather brilliant). There’s game info, pagination, lightbox and other things you’d expect from a site like this.

So far I have seven galleries up there, with three of them being “complete” (L.A. Noire, Mass Effect 3 and Saints Row: The Third). In future I’ll of course add more games and more screenshots as far as my free time allows.

One of my proudest moments so far with YSMB is that one (or more?) screenshots from the Mass Effect 3 gallery were used for a Kotaku article (specifically my custom Shepard). So feel free to use the screenshots, and if you can let me know where and how you used them.

And finally, a big thank you to Maria Miettinen for drawing the YSMB logo which is used around the site. Maybe one day I’ll figure out how to use it more prominently.

While working on a recent WordPress project for a client I needed to list all the attachments/media that had been uploaded for the current post/page that the visitor was viewing.

What I needed was a HTML list with each bullet containing the thumb which was in turn linked to the large version of the image. This is what I came up with:

$args = array('post_type' => 'attachment',
      'numberposts' => -1,
      'post_status' => null,
      'post_parent' => $post->ID,
      'order_by' => 'menu_order',
      'order' => 'ASC');
$attachments = get_posts($args);
if($attachments)
{
  echo '<ul class="imagelist">';
  foreach($attachments as $attachment)
  {
    echo '<li>';
    $large = wp_get_attachment_image_src($attachment->ID, 'large');
    $thumb = wp_get_attachment_image($attachment->ID, 'thumbnail');
    echo '<a href="'. $large[0] .'">' . $thumb . '</a>';
    echo '</li>';
  }
  echo '</ul>';
}

Now one could argue why didn’t I just use the built-in gallery option? For one because it didn’t give me the flexibility I needed. I can expand the above code to include additional rules easily.

For example, maybe I don’t want the “Featured Image” to appear in the list. Easily added. Or maybe my setup would change from “thumbnail” and “large” to something else. Again, easy to change.

I guess one of the things that I miss in G+ (or maybe I just haven’t found it) are short URLs to your profile. Facebook has it, so you can get to my profile by entering facebook.com/rihards into your browser. Short and simple. So I wanted something like that for the other sites that I use (G+, Twitter, Flickr, etc.), but I wanted them to be consistent.

And what better way to do that than to use your own domain, and just set up some redirects? A little research into the difference between HTTP 301 and 307, this was born:

Redirect 307 /+ https://plus.google.com/u/0/114104365088835046723/posts
Redirect 307 /plus https://plus.google.com/u/0/114104365088835046723/posts
Redirect 307 /twitter https://twitter.com/#!/rihards
Redirect 307 /facebook https://www.facebook.com/rihards
Redirect 307 /flickr http://www.flickr.com/photos/rihardss/

Just added that to my .htaccess file and it works like a charm!

If I want to have a look at my G+ profile I can just go to rihards.com/+ and it will take me there.

Now I (or anyone else for that matter) don’t have to remember the exact URL for any of my profiles (and I don’t have to log in to check). As long as I remember what the site is called I can tell people where to find me online.

And of course, I can add/remove/edit these as I please.