Some simple changes I’ve made to Pixelpost
The two things I cover below are only a very small part of the changes I’ve made to Pixelpost, the application I use to power my photoblog, but I figured I’d go ahead and write them out as I’ve received a few e-mails asking for help regarding them.
Prettifying the URI structure
Pixelpost’s URIs are ugly. Take this address for example, which links to a photo of mine:
http://justinblanton.com/photos/index.php?showimage=44
While not entirely unintelligible, it certainly isn’t pretty. I wanted something simpler. Something like this:
http://justinblanton.com/photos/44
It’s actually pretty easy to get this sort of structure using htaccess rules, a process I’ve discussed quite extensively on this site over the years.
The first thing you are going to want to do is edit your .htaccess file, which you’ll need to create if it doesn’t already exist. Place it in the same directory as Pixelpost’s index.php file. Add the following to it:
RewriteEngine on
RewriteRule ^gallery index.php?x=browse
RewriteRule ^([0-9]+)$ index.php?showimage=$1
As you’ll notice, I only concern myself here with the individual picture pages and the thumbnailed archives page (which I just happen to call “gallery”). I don’t account for comments, categories, ratings, or any other such thing here, because I don’t use them on my site (I currently use a pop-up for comments so the URI structure is somewhat moot regarding them; see below). However, it should be fairly simple to recreate those rules by looking at the relevant URI and the rules I’ve shown above. Actually, some things might not be so straighforward, like when the URI uses two or more variables. If I ever start to use any of these I’ll definitely work out the htaccess rules to simplify them and will write about how I did it here. If you’ve a specific question, please feel free to e-mail me.
After making those changes, you need to make another small change to the index.php file. Around line 85, you’re going to want to change this line:
$showprefix = "./index.php?showimage=";
To this:
$showprefix = "./";
Further changes
If you want these modifications to be site-wide, you’re going to have to make some other small changes to the index.php file. For example, to get your RSS feed to link to your posts using the new URI structure, you’ll need to modify the link element of the feed.
Similarly, if you use a pop-up for comments, you’ll want to change the <COMMENT_POPUP> tag to correspond to the new structure (somewhere around line 920). If you don’t do this, then when someone hits the comment button, comments, and then closes the comment window, the address in the address bar, which they likely didn’t take notice of to begin with, will be overwritten with the old URI structure. So, if they choose to link someone to the image, they’ll link using the ugly structure. The end of the world? Of course not, but I like to be consistent.
Putting HTML back into the RSS feed
I’m not quite sure why, but Pixelpost removes all traces of HTML from the RSS feed. This was unacceptable as I link a lot and hated the fact that if someone wanted to follow the link they’d have to go to the image’s page and click on the “info+comments” link where they could then click on the link they wanted. Nevermind the fact that they likely wouldn’t know it was a link in the first place.
In any event, the fix is about as simple as they come. All you need to do is comment out a single line, somewhere around line 800:
$body = strip_tags( $body );
That’s it. The feed should still validate just fine.
Some general stats
I really like seeing this sort of thing on other people’s sites and given that I’ve been asked about some of this stuff before I thought I’d post a few statistics here. The images below are from my Mint installation, which I’ve written about before.



I’m so close
I think I’m about two heartbeats away from buying a Mac Pro. Anyone out there want to try and convince me I shouldn’t?
The photoblog is up and running
Well, I’ve finally launched the photoblog and couldn’t feel more relieved. Now I can get to posting pictures again instead of worrying about how I’m going to post them.
If you build it, they will come
As I briefly mentioned here, one of the main reasons I wanted to integrate the photoblog into my CMS was so that all of my weblog readers would be “forced” to see my photos too (something I’ve kind of been doing here for a while). However, because I’ve decided to use a completely separate system (and won’t splice the feeds together), I have to ask you guys to follow me over there. So, if you’re at all interested (and you better be!), please add the photoblog to your aggregator (see below).
Feed address
http://justinblanton.com/photos/syndicate
Rather receive updates through e-mail? I’ve got you covered.
Navigating the photoblog
Surprise, it’s not complicated. As you can see, the site design is very similar to my current weblog design. It’s very uncluttered and simple — the photo is the focus. So, like most photoblogs, you’ll notice that clicking on a photo takes you to the previous photo and that hovering over the current image gives you the title of the photo and a cue to click to get to the previous photo.
The “gallery” is simply a thumbnail archive of all the pictures.
If you’d like to see what I’ve said, if anything, about a particular photo (e.g., where it was shot, how it was processed, etc.), you’ll want to click the “comments” link. This will give you a pop-up that includes both my thoughts on the picture and those of others who have viewed it. You read that right, I’m allowing comments on the photos (for the time being). So, by all means, share with me your thoughts.
Some things are still in flux
As mentioned above, I’m not sure how long the comments are going to last; as soon as they become more trouble than they’re worth (e.g., spam, immature rants, volume, etc.), I’ll likely disable them (as I’ve done on this weblog).
I’m thinking very seriously about changing the hover text so that instead of telling you just the photo’s name, it would also show you whatever I’ve said about the image (as it stands now, you can see that information only when you click on the “comments” link for each each picture).
There’s a good chance I’ll eventually implement some JavaScript to kind of divide each photo in half so that the left side takes you to the previous photo and the right side takes you to the next photo.
There are a few other things that need to be fleshed out more fully, but they could very well become non-issues depending on the amount of traffic I eventually get. We’ll see how it goes.
Have a look around and please let me know what you think. As usual, I’ll likely write something up discussing the hacks I made to Pixelpost and why I made them, but I wouldn’t expect this any time soon.
Yet another post about the photoblog
As I’ve discussed here a lot lately, I’ve been on the cusp of debuting a photoblog for a while now and am glad to say that the wait is almost over. After determining what would be needed to integrate (but still keep separate) such a thing within my current CMS and coming up with a process to get thumbnails how I wanted them, I still wasn’t convinced that that was the way to go and have really been struggling with which route to take.
I’ve since decided that a separate “container” for the photos is really the only appropriate way to do this thing right and so I’m going use Pixelpost for the job. I’ve made this decision many times in the last few days only to second-guess myself at the last second, but this time it’s final — I’m launching the site tomorrow. It’s funny, after all the consternation and time spent thinking about this, it seems so obvious to me as I write this post that using a separate system is the only way to go.
I know some of you couldn’t care less about this debate I’ve been having with myself, but it’s hard for me to move forward on something like this unless I know there is an escape route for the future. While I’m still a bit iffy about using Pixelpost, and will probably lose sleep thinking about how five years from now I might be struggling with a way to export the then no-longer-updated Pixelpost data into something else, I’ve decided to throw caution to the wind and run with it. I figure Pixelpost is the most popular photoblog software in the world and so someone1 will probably work out a way to export it into other things if and when such time comes that it’s no longer maintained (even if that someone is me :).
It’s all in my head
I apologize to those who wrote in (quite a few of you actually) asking me to do a full write-up on the integrated-into-WordPress solution I worked out. Though I’ve decided not to go in that direction, I have the whole thing mapped out in my head and am perfectly willing to help you out if you think you might want to give it a try. Hell, I may even write the whole thing out here anyway. We’ll see. In any event, don’t hesitate to send over questions if you have them.
-
Indeed, as I mentioned about a month ago, the upcoming pixyBlog software will allow you to import from Pixelpost. ↑
Peppering Mint and filtering referrers
Lately I’ve had quite a few people ask me what Peppers I currently use with Mint and so I thought I’d rattle those off fairly quickly here.
- Fresh View
- Trends Internal
- Trends External
- Session Tracker (link is to archive file; site has been taken down)
- Outclicks
- Download Counter
- FeedBurner Stats
- XXX Strong Mint
Filtering images.google.* referrers
In my initial post about Mint I wrote the following:
There is no way to filter the RSS feed. In other words, there is no way to remove from it things that come up often, but in slightly different contexts (e.g., I get a ton of referrals from Google Images which I couldn’t care less about). Yes, I know of the Referrer Filter Pepper, but it only filters the page view pane, not the RSS feed.
It turns out that this can be resolved rather easily by specifying, in the referrers section of the preferences page, those addresses you want Mint to ignore. The language above the text box is a little confusing and might make you think that the addresses added won’t be filtered out of the RSS feed (”Don’t show referrals from the following domains in the Newest Unique Referrers tab…”), but I can assure you they are.
Unfortunately, this filtering system doesn’t support wildcards (e.g., images.google.*) and so you have to add each and every address you want to filter (e.g., images.google.cg, images.google.com.hk, etc.). Lucky for you, I’ve been generating a list of all the Google Images domains for quite a while now and am making this list available for download so that you don’t have to do the same.
Simply copy/paste my list into the text box in the referrers section of the preferences page and click “Done.” That’s it. If you come across some domains that aren’t in the list, please e-mail them to me.
Something tells me that Shaun will create an “on/off” option in future builds to control the referrers from Google Images (it’s the only thing I filter for and I know a lot of other people are in the same boat; perhaps even Shaun), but until then, this method works like a charm.
Back in black
I’m back from the cruise and probably as tan as I’ve been since high school (when I was on a lake every day wakeboarding and whatnot). Still debating whether I want to do a full-length write-up on the experience or just get to all the tech stuff I want to talk about.
Just in case I don’t get around to doing a longer post about the trip, I’m going to try to quickly and nonsensically rifle through some of the ‘highlights’ without too much thought.
- Itinerary: left out of Ft. Lauderdale, then headed to Princess Cays in the Bahamas, Ocho Rios in Jamaica, Grand Cayman in the Cayman Islands, and Cozumel in Mexico.
- While I had a great time and would probably do it again, it all felt a bit rushed when hopping from country to country.
- I ate like a king and couldn’t stop myself. It was kind of ridiculous. As ever, I didn’t gain a pound.
- Some of the ship activities were a bit too froufrou and snooty for my liking.
- I feel somewhat heretical saying this, but I didn’t miss the Internet as much as I thought I would, though once I stepped off the boat I was painfully thirsty for my data drip.
- Airline officials can ask an entire plane full of people, with a straight face, for two volunteers to take a different flight because their collective body weight puts us over FAA regulations, and then expect us to feel comfortable at 35,000 feet knowing that rain water might be enough to bump us over the limit. I should note that this took over two hours to figure out. Yep, we sat on the tarmac for two hours while they debated whether the plane could keep us in the air. I’m telling you, the Flying Spaghetti Monster hates me.
- Cruise lines don’t employ funny comedians. I could have run circles around any of them. It was literally painful to watch.
- Cruise lines do employ great jugglers.
- Alcoholic drinks weren’t as expensive as I had expected, and, ironically, I drank much less than I thought I would.
- Due to the latest terrorist scare, if you buy a bottled beverage in an airport you now “surrender the cap at the time of purchase,” lest you could pour out your orange juice and fill the bottle with the liquid you’re currently somehow carrying without a bottle and which you already got past security. What a joke. Who’s up for flying naked and buying new clothes on the other end? I’m afraid that’s where all of this is headed.
- I refuted my girlfriend’s oft-made assertion that I’m a pessimist by stating that I’m a realist. She still didn’t buy it, so I told her I’d meet her in the middle and dubbed myself a pessimistic realist.
- There were 3700 passengers on our ship and the crew numbered over 1200. The massiveness of everything related to the ship cannot be overemphasized and I think I may write up a separate post wherein I discuss all the ship statistics I gathered over the week.
- Every other person in Jamaica thought I was a drug addict and offered me everything under the sun. If they didn’t think I was a drug addict they thought I needed a taxi. It was absolutely insane and all of the badgering and harassment actually made most of our time on the island pretty stressful.
- I planned to get though the audiobooks of Charlie Wilson’s War and Freakonomics, but it never happened; there was just too much to do on the ship and at the ports.
- I didn’t take as many pictures as I would have liked, but I think I got some pretty good stuff and can’t wait to get it up here.
- Everything everywhere was a bit too Americanized.
- The stateroom stewards are magicians.
- A homeless guy in Jamaica asked me to take his picture. I did, and gave him $5. He then spent the next five minutes digging through a plastic bag and eventually asked me to write his address down on a piece of paper so that I could send him guitar strings or something. The address as he gave it to me: Johnny Cool, Post Office, Ocho Rios, Jamaica.
- It didn’t matter how many times I went up and down the stairs of the “fiesta boat” I was on, as soon as I got near the top of the stairs the man selling t-shirts (who I passed at least 20 times) would simply say, “What size and how many?” He almost had me on his 33rd effort, but I just couldn’t convince myself that I needed an “official” t-shirt to remind me of the boat.
- I was probably in a bathing suit more than any other person on the ship.
- Internet access on the ship worked great, but at $22/hr it was out of
myanyone in their right mind’s budget. It’s almost laughable that they can get away with charging so much. I don’t get it. - After going through the 9000+ posts that had built up in my aggregator over the last week+, I realized that I really didn’t miss anything.
- I learned that a lot serious art is sold on cruises (more than 300,000 pieces last year!). Went to a few art auctions and really enjoyed them, even though I had no intention of actually buying anything. OK, so the free champagne roped me into the first one, but I went to the others because I enjoyed them.
- Despite the fact that I was on a cruise and having a good time, I still found it hard to relax. It’s my lot in life I suppose.
- It makes little difference where in the Caribbean you go — the water is going to be beautiful and clear regardless.
- Some people responded to the totally non-personal auto-response I setup for my e-mail as if I was writing them personally (even though the message clearly stated I was on a ship in the Caribbean).
Well, that ended up being longer than I would have liked. Anyway, if the longer post never comes, I’ll try to give a few more details of the trip as they coincide with some of the shots I’ll eventually post here.
Incommunicado
As mentioned briefly before, tomorrow the girlfriend and I are headed out on a cruise to the Western Caribbean and so you can expect this space to be dead for at least the next week. Not sure what my net access is going to be like on the ship, but something tells me I’m not going to be able to convince myself to fork over the $22/hr they charge for it (yes, that’s the actual rate; utterly ridiculous), no matter how many Margaritas I have in me. It’s a coin toss as to how my brain will react to the deprivation.
The end-goal is to simply relax (easy to say, but…), which will involve me stuffing my face, thinking about the bar as little as possible, and taking some [hopefully] unbelievable pictures.
I’ve much to post when I get back, so hold your breath and I’ll see you in a week.
Introducing Prolific for WordPress
Well, I’ve just put the finishing touches on yet another WordPress plugin (my fourth). This one basically gives you a word count of all the posts in your WordPress weblog and updates itself automagically each time you publish a new post. To download the source, please see the project page.
The impetus behind the plugin was speed, or rather, the lack of it. I whipped up some simple PHP a couple of years ago to extract a word count from WordPress, a statistic I keep on the archives index, but because of my Smart Archives plugin, that page takes a few seconds to load (I don’t think it can be made any faster) and any extra time spent calculating the word count was only adding to the delay. Though WP-Cache has pretty much made the speed hang-up a non-issue, I still didn’t like the fact that I was calculating the word count each time the page expired from the cache.
I didn’t want to call it a “plugin”
I’m fully aware that this is a niche plugin if there ever was one, but if you are a stats junkie like me you’ll likely appreciate it.
The tour page is up
The tour is finally complete. After deciding how I was going to lay out the page (something I finalized months ago; it’s nothing groundbreaking), I was left to sift through my posts and find those I wanted to use on it. This actually took me a very long time and the page’s posts will probably remain in flux indefinitely.
After struggling to find a usable solution for presenting post excerpts that (1) was non-destructive and (2) didn’t require me to mark within a post where I wanted the excerpt to end, I just decided to run the full posts, which, after really thinking about it, is the only thing that makes sense anyway.
Let me know what you think.
Google Hacks, 3rd Edition
Paul Bausch, author of the third edition of Google Hacks, for which I was the technical editor, has just put up a few words about the newly released book. Have a look at what he has to say and then purchase the book. :)
Teaching Image Magick who’s boss
A few days ago I asked if anyone knew how to get “either Image Magick or NetPBM to create square thumbnails built from the largest square that can fit inside the center of the original image?”
While I received a few e-mails from others wanting the same, no one had a solution for me and so I had to fight off empathy and figure it out on my own (even though I was told it couldn’t be done). I would have typed this up sooner, but a good friend of mine is currently working with a new social-networking startup and thought that I might be able to use this (+ some other Image Magick/PHP voodoo) to make a quick buck, and so I had to wait for that situation to resolve itself.
Without getting into the details and at the same time gracefully skirting around how much time I spent on this, I’ll just show you the command and tell you what you need to change if you want to do it for a larger/smaller thumbnail.
convert filename.jpg -thumbnail x170 -resize '170x<' -resize 50% -gravity center -crop 85x85+0+0 +repage newfile.jpg
The above is for an 85×85 pixel thumbnail. Notice that the first two numbers (the 170s) are twice the width/height of the final thumbnail I wanted to create; given those relations you should be able to deduce what you’d need for a different sized thumbnail. Note that this command sequence also seems to work quite well for portrait images (i.e., where the height is greater than the width).
Prettify your shell prompt
I’ve used the same shell prompt for ~10 years now. 10 years. The colors I use come from an old IRC friend’s bash configuration utility (I probably have the script source buried deep in some archives somewhere).
You’ll notice that the prompt tells you the current user’s username, the hostname of the machine, and the current folder.
If you’d like something similar, simply place the following line in the .bashrc file of your home directory.
PS1="[\033[1;30m][[\033[1;36m]
\u[\033[0;36m]@[\033[1;36m]
\h[\033[1;30m]][\033[0;36m]:[\033[1;36m]:[\033[0;37m]
\W[\03[1;36m>[\033[0m] “
Realize that it should all be a single line (I broke it here so that it would fit nicely and be a bit easier to read).
Mirrored
You know, I don’t know what it was about studying for the bar, but it really seemed to force me into some serious self-reflective moments and not a day went by that I didn’t semi-consciously drift into a daydream about my past. I really thought a lot about where I’m at in my life, all the wonderful experiences I’ve been fortunate enough to have, and all of the incredibly crappy things I’ve somehow managed to overcome (externally at least). It really is a small wonder that I’m here, in California, on the cusp of beginning my career at a prominent IP firm.
It’s been an awfully wild and tumultuous ride, this life thing, and it’s just incredible to sit back and think about all that’s happened and how all of those things have, for better or for worse, shaped me into the person I am today. It’s overwhelming.
I can only imagine what it must feel like to think similarly of your progeny. I’m going to act like such a girl when I have kids, I just know it.
Building a photoblog off of a weblog
Update (2): While the previous update intimated that I wouldn’t have to modify anything in the WordPress source should I choose to go the route outlined in this post, I’ve come to think that isn’t possible. It looks like I’m going to have to modify both functions so that they return only the actual URI and nothing else. The changes themselves are very simple, but it’s just one more thing to keep track of when upgrading next time around.
Update (1): The possible issue I mentioned at the bottom of this post is not an issue it all. Turns out that WordPress has arguments built into the next_post_link() and previous_post_link() functions that “indicate whether the next/previous post links must be in the same category/categories as [the current post].” Yay, one less plugin to write if I end up taking this approach.
All this talk about getting the photoblog up and running has really sent my mind into overdrive trying to come up with a simple solution that would allow me to use the same backend (and subsequently the same posts) to power two completely separate sites (i.e., the weblog and the photoblog), instead of using an “external” photoblog application. More to the point, I want to continue posting pictures to the weblog as I’ve been doing for a while, but I also want to use those same posts as entries into a separate photoblog, which will use the various elements of the posts differently than the weblog.
The benefits of such a sysem are two-fold. First of all, it would ultimately be less work for me once it’s all up and running (i.e., I would just post once as normal and the rest would be handled automatically). Second of all, if there comes a time in the future when I don’t want to have a separate photoblog anymore, I can just discontinue it without losing everything that went into it (i.e., it will all be saved as just a regular part of the weblog).
I think I may have come up with a solution and am going to throw it out there to see what kind of response it gets. To me, this seems like the most elegant way to go about it and it minimizes the probability of future problems (e.g., if you change to a different CMS) as it’s as bare bones as possible and all you’ll really ever need to change is the code that specifies the file size (because presumably any CMS you move to will easily map to the post elements I discuss below).
The very simple solution
To start with, let’s list the various pages that will need to access and manipulate the photography posts:
- Weblog index page
- Weblog yearly/monthly/individual archive pages
- Weblog RSS feed
- Photoblog single-photo page
- Photoblog thumbnail page
- Photoblog RSS feed
Each of the above pages will need at least one of the photo sizes listed below:
- Small — 85 pixels wide (for the page of thumbnails)
- Medium — 500 pixels wide (for the weblog)
- Large — 800 pixels wide (for the single-photo pages of the photoblog)
These images will be created and uploaded to the site as filename-s.jpg, filename-m.jpg, and filename-l.jpg, which correspond to the three different sizes.
Looking at WordPress, we see that it gives us just three [post] variables to work with, namely title, content, and excerpt. We’ll use these variables in the following way:
- Title — as you would expect
- Content — description of/thoughts on the photo
- Excerpt — the filename of the photo without the suffix
So, the excerpt will contain the filename of the photo, but will not specify any particular size. However, we can use PHP (or whatever) to append the correct size (i.e., -s, -m, or -l) to the filename, and we will know the correct size because this can be hard-coded depending on which template we’re using (e.g., weblog index).
Walk-through
When the system is fully functional and all the code is in place, it should work something like this when publishing a new picture:
- Work some Photoshop magic on the next picture we want to put up.
- Save the image to a temp directory.
- Run a shell script that will create three images from the original: one 500 pixels wide (constrain proportions), one 800 pixels wide (constrain proportions), and one 85 pixels wide as per my earlier request for help.
- The above script will name the files based on the original filename (e.g., if the file was originally saved as filename.jpg, it will create filename-s.jpg, etc.)
- Upload these files to our webserver.
- Create a new post in WordPress. Remember, in the excerpt field we’re going to want to put the filename without the extension or size identifier.
- Be sure to put the post into a “photos” (or similar) category so that we can separate these posts from non-photo posts.
- That’s it! The various templates will add the needed file paths and will use the correct filename depending on the page being generated.
If you can shoot any holes in this approach please e-mail me and let me know. The only thing I haven’t given too much thought to is how I’m going to create the next/previous links needed for the photoblog. This could be a bit tricky because the links will have to be confined only to those posts categorized as “photos” (or whatever). I haven’t looked yet, but perhaps this functionality is built into WordPress. If not, I could probably write a plugin, but I’d rather stay away from non-standard band-aids if at all possible.