rendered paste body<?php
/**
* Plugin Name: Teaser Image
* Plugin URI: http://www.headzoo.com
* Version: 1.0
* Description: Teaser image for posts
* Author: Sean Hickey
* Author URI: http://www.headzoo.com
*/
add_action('the_teaser_image', 'tsr_theImage');
function tsr_theImage($defaultImage = null) {
global $post, $wpdb;
$image = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE post_parent = $post->ID AND post_title LIKE '%tsr-%' LIMIT 1");
if (empty($image)) {
if (empty($defaultImage)) {
return;
}
$image = $defaultImage;
}
$permalink = get_permalink($post->ID);
echo "<a href=\"$permalink\" title=\"$post->post_title\" class=\"teaser-link\"><img src=\"$image\" alt=\"$post->post_title\" class=\"teaser-img\" /></a>";
}
?>