Archive for category Usability
Speeding up Pixelpost blog browsing
Pixelpost is a very popular framework for photoblogs due to its simplicity and ease of tweaking. A while back I posted an article on how to enable keyboard navigation on a pixelpost photoblog. It works very well considering it allows mouse free browsing. But the browsing experience can be improved even more.
Lets consider how a photoblog is browsed most of the time. A visitor typically lands on a home page showing the latest image and goes through the previous images sequentially, spending a few seconds on each image. Leveraging this fact, if the “previous” image is downloaded in the background using javascript right after the current image, it will be almost if not completely ready for viewing when the visitor is on the “previous” image page. The same can be done for the “next” image, but in most of the cases that image will already be in the browser cache.
This is a very simple change for a tangible usability benefit. Below are my tweaks:
index.php:
// expose the previous image name through tags, so previous images can be
// pre-downloaded in the background for faster browsing experience
$tpl = ereg_replace("<IMAGE_PREVIOUS_NAME>",$image_previous_name,$tpl);
templates/theworldin35mm/image_template.html:
window.onload = function() {
...
var prevImg = new Image(); // for downloading prev image in background
img.onload = function(evt) {
...
// after current image load, load previous image in the background
if('<IMAGE_PREVIOUS_NAME>' != '') {
prevImg.src = '<SITE_URL>images/<IMAGE_PREVIOUS_NAME>';
}
}
...
};
To verify that this extra javascript is actually doing its job, look at the Net section in Firebug (in Firefox browser, ofcourse). Clear the cache first. On first page load it will show several items getting downloaded. On left arrow, the previous image page will load, and then you can see that an extra image got downloaded at the bottom. Compare with and without my code. Here is a screenshot:
Pixelpost mod: Edit image link
As my pixelpost photoblog is growing by the day, it is pretty painful to edit info for images that are a little old. In the admin page, go to the images section, then navigate a couple pages to find the image from the small thumbnail then click edit. Too much work for me. A simple tag expansion should solve this.
So I made this new tag and inserted it right after the Admin link in the footer page (my template is theworldin35mm):
<EDIT_IMAGE_LINK_ITEM>
And then the following piece of code in index.php to ensure expansion of the tag only on a image page and when logged in:
-
$edit_image_link_item = "<li><a href=\"<SITE_URL>admin/index.php?view=images&id=$image_id\" title=
-
\"Edit Image\">Edit Image</a></li>";
-
} else {
-
$tpl = ereg_replace("</edit_image_link_item><edit_image_link_item>","<!– Edit image link only for image page when logged in –>",$tpl);
-
}
The above code goes right after the following block:
-
…
-
}
Image management (editing category/tags) is a breeze now.
The importance of keyboard navigation
While browsing online portfolios of a few well known photographers I noticed how desperately those fancy designs needed a very basic feature – keyboard navigation. Thanks to the deluge of digital photos everywhere and the tendency of people to upload a gazillion of them after every party or a trip, we no more have the time or patience to point and click the “next” link. Picasa, smugmug and facebook among a few others have already put this most important feature in place, making it a pleasure to browse images quickly. Too bad flickr did not yet, but it is nothing a greasemonkey userscript can’t fix.
Then I wanted this on my own photoblog as well. I thought about using jQuery but since pixelpost uses prototype, I looked up the syntax and quickly came up with this small piece of code:
-
Event.observe(document, "keypress", function(e) {
-
// 37 for left, 39 for right
-
var cur = location.href;
-
var prev = $$("#image-nav-prevlink a")[0].href;
-
var next = $$("#image-nav-nextlink a")[0].href;
-
switch(e.keyCode) {
-
case 37:
-
if(cur != prev) { location.href = prev; }
-
break;
-
case 39:
-
if(cur != next) { location.href = next; }
-
break;
-
}
-
});
10 minutes of effort. 10x better usability.
Update: I made a flickr photostream navigator userscript in a similar fashion but had a critical bug. When an input box is focused, arrow keys should not trigger another page load. The same bug is present in the above code as well. Thanks to my good friend Francesco for catching this early. I fixed them both. The above code after correction looks like:
-
var PB = { Globals:{} };
-
PB.Globals.inputHasFocus = false;
-
-
Event.observe(document, "keydown", function(e) {
-
// console.log("any input has focus: " + PB.Globals.inputHasFocus);
-
if(PB.Globals.inputHasFocus) { return; }
-
// 37 for left, 39 for right
-
var cur = location.href;
-
var prev = $$("#image-nav-prevlink a")[0].href;
-
var next = $$("#image-nav-nextlink a")[0].href;
-
switch(e.keyCode) {
-
case 37:
-
// for some reason the inactive link looks like "…showimage="
-
if(cur != prev && prev.match("showimage=[0-9]")) { location.href = prev; }
-
break;
-
case 39:
-
if(cur != next && next.match("showimage=[0-9]")) { location.href = next; }
-
break;
-
}
-
});
-
-
Event.observe(window, "load", function() {
-
$$("input.input, textarea").each(function(inp){
-
inp.observe(‘focus’, function(e){
-
// console.log(e);
-
PB.Globals.inputHasFocus = true;
-
});
-
inp.observe(‘blur’, function(e){
-
// console.log(e);
-
PB.Globals.inputHasFocus = false;
-
});
-
});
-
});

Recent Comments