So to start, I will describe exactly what I was trying to do and give a little background. I did a lot of googling, and it seems that no one really had put together a tool to do what I wanted so I had to piece it together a bit myself. Perhaps, when I have more free time, I can convert it into a plugin so it will be even easier for someone to use. In my blog, I have a category called "Mobile" that is used whenever I post items from my phone. This virtually always consists of me posting a picture that I took on my phone, so I wanted to try to set it up similar to Twitpic or any other Twitter photo hosting site. I wanted it to work identically, but use my own web space instead of having some third party host, and do what they like with, my pics. One of the only means I found to do this involved having an Android app that allows the user to use a custom photo hosting site (most only give choices of several popular ones). The only app I found that allows this wouldn't talk to the code I had set up on my site so I abandoned that idea and decided to just stick with having "Mobile" posts with a single pic as part of my blog. While a user can view all posts in a category, it seemed a little cumbersome to scroll through pages of posts that just included a single pic and a few words so I decided I wanted to just put together a gallery of pictures posted. I found many photo gallery plugins, but, surprisingly, none had enough customization to automatically populate the gallery from my posts. After a little searching, I discovered
this post on the Wordpress support pages. It has some php code for getting the first image from Wordpress posts, and, since all my "Mobile" posts have a single image, that is exactly what I needed (though it would be pretty simple to modify to grab all images if someone wanted a gallery of all images posted to their blog). It used another utility called
TimThumb, which creates thumbnails of the images. This worked pretty well, but the result was ONLY a gallery of thumbnails. My preference was to have the ability to click each pic and it would take you to the associated post, but, at the very least, I wanted to have each thumbnail link to the full resolution pic. So I created a new page template in my wordpress theme and included the php code. I didn't worry with formatting because the thumbnails just tile to fill the space. I had to modify the code a bit so that it would grab only from the "Mobile" category and to make each thumbnail link to the full resolution picture. I was pretty happy with
the result. So now, every time I post from my phone it creates a new blog post, and there is a
gallery of all the pictures from the posts from my phone that can be viewed all together. Kinda snazzy! I still have a couple of tweaks that I would like to do, though.
- As mentioned earlier, I would like the link to take the user to the post associated with the pic, not just the full resolution. I would like this because I always have a title and sometimes have additional text associated with the picture. I am also entertaining the idea of combining the title and post text and having them be the ALT text for the thumbnail in the gallery. Then a user could hover their mouse over a pic and see the text associated with it but wouldn't have an additional step to get to the full resolution version.
- I would also like to get comments working so people could comment on the entire gallery. This would probably be only useful if I haven't implemented #1 yet because, as it is, there is no way to comment on a single pic without just searching through the posts. I have tried to put the code to add commenting to the bottom of the page, but for some reason it never shows up. I am too unfamiliar with wordpress and it has been too long since I really used PHP to figure it out at a glance.
- The last thing that would be nice to do is to package this up as a plugin. Then make it easy to customize where the pics you want displayed will come from and add some formatting options. What would be IDEAL is if I could also create a (or tweak an existing) plugin like WP to Twitter that automatically tweets when I make a post so that the resulting tweet would be the title followed by a link directly to the photo. This should allow most Twitter clients that have previews to see the photo and people could get a glimpse instead of just having a link they would have to click on (i.e. it would work exactly like Twitpic).
None of these will likely happen until I have finished with my dissertation, but it never hurts to have plans in mind. Hopefully, people that want something similar in their blogs will benefit from this post!
No comments:
Post a Comment