0

i'm using an rss to post plugin. The posts fetches from the RSS do not have any pictures associated with them. Is there a way to automatically assign a 'featured image' to posts from a category?

Another option is that in my WP theme, with the custom field as 'thumb' I can add images/reuse same images.. is there a way to make use of this and assign a default pic to all posts from a category?

Edit: Based on Martin's suggestion I installed the get image plugin. The code mentioned in the read me is this:

get_the_image( array( 'default_image' => 'http://www.mydomain.com/wp-content/uploads/defaultimage.png' ) );

However, my theme isn't that direct. It makes use of a function in the functions.php file.

// Get image attachment (sizes: thumbnail, medium, full)
function get_thumbnail($postid=0, $size='full') {
    if ($postid<1) 
    $postid = get_the_ID();
    $thumb_key = get_theme_mod('thumb_key');
    if($thumb_key)
        $thumb_key = $thumb_key;
    else
        $thumb_key = 'thumb';
    $thumb = get_post_meta($postid, $thumb_key, TRUE); // Declare the custom field for the image
    if ($thumb != null or $thumb != '') {
        return $thumb; 
    } elseif ($images = get_children(array(
        'post_parent' => $postid,
        'post_type' => 'attachment',
        'numberposts' => '1',
        'post_mime_type' => 'image', ))) {
        foreach($images as $image) {
            $thumbnail=wp_get_attachment_image_src($image->ID, $size);
            return $thumbnail[0]; 
        }
    } else {
        return get_bloginfo ( 'stylesheet_directory' ).'/images/default_thumb.gif';
    }

}

// Automatically display/resize thumbnail
function tj_thumbnail($width, $height) {
    echo '<a href="'.get_permalink($post->ID).'" rel="bookmark"><img src="'.get_bloginfo('template_url').'/timthumb.php?src='.get_thumbnail($post->ID, 'full').'&amp;h='.$height.'&amp;w='.$width.'&amp;zc=1" alt="'.get_the_title().'" /></a>';
}

I need help in adding the get_the_image function into the one above so it checks.. If category id=120, then display mydefaultimage.png else, do the regular thing.

Thanks.

1 Answer 1

1

if i understand your question correctly then have a go with Justin Tadlocks get the image plugin, olden but golden and does the default image per category etc.

1
  • Thanks Martin, will give this plugin a test ride and see how it works out? Commented May 21, 2011 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.