WordPress Moblogging with "Postie"

As you may have noticed, a couple of posts showed up over night, the last few in the rather wee hours of the morning. This was the byproduct of my discovering another new WordPress plugin a couple hours ago, called Postie.

Postie is a plugin designed to make it easier to post entries by email, which can potentially (such as in my case) come from a cell phone with images attached. It has a lot of cool features like letting you specify the tags for new posts (something I can’t do when posting through Flickr), as well as automatic thumbnail creation, the ability to rotate the picture by requesting it from the phone, and a bunch of other nice touches.

For the short term, I’m going to be giving Postie a try for moblogging, instead of using Flickr like I have in the past. The only noticeable change to you, the reader, is that the template is slightly different, and there is not (for the time being) a gallery of all the past moblog photos in one place. (Previously you could visit my photostream on Flickr)

Not to worry. You can already view the most recent posts by using the Categories feature of WordPress, located on the right side of the page. Head on over to Moblog (or click on “Moblog” at the header of this post) to see all recent mobile posts. These categories are automatically updated when new posts are made.

Of course, you know me… I’m not having fun until I’m sifting through the code to figure out what makes it tick, and adding my own little tweaks and modifications. So over the past couple hours I made a few little changes that other WordPress users might be interested in. For most other ordinary people, consider this your forewarning that this post is about to degenerate into code samples 🙂

One thing I really wanted from Postie was the ability to automatically add the necessary HTML code to activate SmartBox on the images I post from my phone. This also led me to getting rid of the JavaScript call for popping up a new window when clicking on a thumbnail. I ended up solving these features by making both of them optional, and adding appropriate configuration options to config_form.php. You can add these features by making the following changes:

In postie-functions.php, around line 396, replace the original

if ($thumbImage) {
. . .
}

block with the following code:

if ($thumbImage) {
    $marime=DetermineImageSize($file);
    $marimex=$marime[0]+20;
    $marimey=$marime[1]+20;
    //Edit: Removed $mimeTag, as I don't really need that cluttering up
    // my posts unless something goes wrong.
    $newAttachment = '' . "n";
    $attachments["html"][] .= $newAttachment;
    if ($cid) {
        $attachments["cids"][$cid] = array($config["URLPHOTOSDIR"]
            . $fullImage,count($attachments["html"]) - 1);
    }
}

Then, around line 1785, add these two lines, to set defaults for the new config options:

    if (!isset($config["USE_POPUP"])) { $config["USE_POPUP"] = true; }
    if (!isset($config["USE_LIGHTBOX"])) { $config["USE_LIGHTBOX"] = false; }

Finally, in config_form.php, you need to add these two entries. I like them around line 233.

< ?php echo BuildBooleanSelect("Enable Lightbox For Thumbnails","USE_LIGHTBOX",$config["USE_LIGHTBOX"],"Has no effect without one of these plugins: Lightbox, Litebox, or SmartBox");?>
< ?php echo BuildBooleanSelect("Enable Pop-Up For Thumbnail Links","USE_POPUP",$config["USE_POPUP"],"Yes will cause thumbnail images' link to the full size version to open in a new window.");?>

Leave a Reply

Your email address will not be published. Required fields are marked *