Each post I make has a nice little handcrafted featured image to go with it.
I want to to put (say) 10 stacked random images in the sidebar (no text, just the thumb with some canvas around it), resized to 150x75 and clickable to take someone to the post it represents.
In the last week I must've tried every widget that has anything at all to do with featured images and the sidebar, but I still cant find anything.
I found one (special recent posts) which does EXACTLY what I want, but it only takes its images from the last X recent posts. I contacted the author and asked if he could tell me how to make it choose from all blog posts, not just the last few. He said it stretched the plugin too far and he had no plans to implement anything like that
The closest thing I've found myself is to use the php widget (mentioned elsewhere in this forum) and use the following
Code:
<?php $thumbnails = get_posts('numberposts=10&orderby=rand'); foreach ($thumbnails as $thumbnail) { if ( has_post_thumbnail($thumbnail->ID)) { echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">'; echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail'); echo '</a>'; } } ?>
Can someone either suggest a plugin I could try that does what I want, or failing that give me some ideas of how to go about getting this code to work as I want?
Thanks
EDIT
I've managed to work out that putting this as a css insert will place it where I want it, and resize the image, but it doesn't do a 'proper' job - images seemed squashed or stretched to fit. There must be a better way
Code:
img.wp-post-image { background: none repeat scroll 0 0 transparent; border: 1px solid; margin: 0 0px 5px 16px; width: 150px; height: 75px; padding: 0; }
Edit 2
Ok, I've realised that you cant really use CSS to resize an image.
The widgets that do resize use routines and methods that are beyond me.
I've manually resized the thumbs to the size I need, and using the bit of php and css from above I've got a passable result
Hope that helps someone else