Adding Random Images to Every Post
May 11, 2009
Many premium WordPress themes make extensive use of thumbnails or featured images in your posts, but many feeds just don’t provide good images to work with. Rather than letting this feature go unused, there is a little trick you can use to add images to each post.
In one of our sample sites AdvertiserGuide.us, we are using the very cool Gazette Edition theme by WooThemes. The design of this theme relies heavily on the cross-fading featured images at the top, as well as thumbnails for each article, but most of the articles we were using simply didn’t have any associated images.
To fix this, we went to sites like istockphoto.com and www.sxc.hu to download both free and purchased stock photos that seemed relevant to the theme, yet generic enough to use with any article. We gathered 50 good photos, resized them all to the same size, and then renamed them 1.jpg through 50.jpg and uploaded them to our site.
Next, for each feed that doesn’t produce good images we added a custom field in AutoBlogged called Image. Note that the Gazette Edition theme specifically looks for images in this custom field. We set the value of the field as follows:
http://advertiserguide.us/img/[1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|
24|25|26|27|28|29|30|31|32|33|34|35|35|37|38|39|40|41|42|43|44|45|46|47|48|49|50].jpg
Below is a screen shot of that setting:
You can use post template syntax in your custom field values and bracketed values separated by pipes indicates to AutoBlogged to pick a random value from the list. In other words, AutoBlogged will randomly pick a number between 1 and 50 to create Image field values like these:
http://advertiserguides.us/img/13.jpg
http://advertiserguides.us/img/8.jpg
http://advertiserguides.us/img/41.jpg
http://advertiserguides.us/img/19.jpg
With just 50 images we do sometimes get two or more articles with the same picture on the front page but for the most part that isn’t that big of a deal and it greatly improves the look and professionalism of the site.







Comment Form