Postie and featured images
It took me a bit of messing about to get the blog how I wanted it with regards to looks and also ease of posting.
I need to be able to post from my iPhone, including media, mostly images. I wanted to be able to post multiple images and also be able to set one of them as the “featured image” as that is a requirement of the theme I’m using. The featured image is the one that shows on the post listing pages and the main page.
I decided to use the Postie plugin and blog via email.
Here is how I have it setup currently:
- WordPress 3.2.1
- Slightly modified Unstandard theme
- Postie plugin – to blog via email (modfied – details below)
- Javascript chat for wordpress plugin – like the old days!
- Lightbox Gallery plugin – Postie adds images as a “gallery”, lightbox makes viewing more elegant
- WPtouch plugin – to make viewing from mobile devices nicer – needs mods though!
- WordPress Mobile Admin plugin – is useful for using the admin from mobile devices
Modifying Postie to set the “featured image”
Inside postie/postie-functions.php there is a function called postie_media_handle_upload – this function does what it says on the tin, it handles the media uploads!
When Postie is processing an email it will call that function once per image attachment so what we need to do is add some code to also populate the relevant part of the database to set the image as the “featured image”.
To do this we simply add this code to the end of the function (just before the “return” statement):
update_post_meta($post_id, '_thumbnail_id', $id);
This is a simple hack and does mean that each time an image is processed the code will set that one as the featured image for that post meaning the last attachment to be processed will become the featured one. I will quite often be including multiple images and couldn’t think of a simple way to specify which image is the one you want as the featured one so will have to work with this fact. I have figured out on my iPhone how to get the picture I want to be the last one processed so can control this anyway. I also haven’t tested what happens if you attach a video and that is the last one to be processed as the name of the function suggests it deals with video attachments too.

Discuss - 3 Comments
Slick. I’m having that idea.
I honestly thought that was a pic of you at first when i saw it on my phone
Lol. That’s the guy that made the Postie plugin