Support » Fixing WordPress » Post thumbnail fristrations

  • Resolved manntis

    (@manntis)


    Sometimes WordPress takes the first image I add to an article and makes that into the post thumbnail. Other times it takes the second. Or whatever inage it feels like. And even if I remove the image from the article, IT KEEPS IT AS THE THUMBNAIL.

    Bloody hell this is frustrating. Why can’t there be a “Use as thumbnail” checkbox in the image upload? And why the hell does it keep the thumbnail even if you remove the image because WordPress decided to arbitrarily use the 2nd one uploaded instead of the first, or vice versa? Some predictabiity in what WP is going to do would be friggin appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Sounds like this is something that’s theme related, because WP doesn’t do any auto inserting of thumbnails. what kind of thumbnails are you talking about? The gallery shortcode ones, or ones that have been inserted via the media manager?

    the thumbnails that are generated from images placed in articles, then used on the main page article summaries.

    I grab them using

    dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"');

    which calls

    function dp_attachment_image($postid=0, $size='thumbnail', $attributes='') {
    	if ($postid<1) $postid = get_the_ID();
    	if ($images = get_children(array(
    		'post_parent' => $postid,
    		'post_type' => 'attachment',
    		'numberposts' => 1,
    		'post_mime_type' => 'image',)))
    		foreach($images as $image) {
    			$attachment=wp_get_attachment_image_src($image->ID, $size); ?>
    
    <img src="<?php echo $attachment[0]; ?>" <?php echo $attributes; ?> />
    <?php
    		}
    }

    I found a workaround.

    if you add this code to your functions.php:

    if ( function_exists( 'add_theme_support' ) ) {
    	    add_theme_support( 'post-thumbnails' );
    	    set_post_thumbnail_size( 80, 80, true );
    	}

    it creates a menu in the right column of your admin panel for editing posts that lets you select which image to use as the thumbnail. Modify the 80 x 80 to whatever dimensions you prefer.

    *whew*

    No, I spoke too soon. Adding that code gives you the *illusion* of being able to set which one you want as the thumbnail.

    WordPress still does whatever it bloody well wants, and it’s usually the exact opposite of what you want it to do.

    Add two photos? Sometimes it’ll use photo A as the article thumbnail, sometimes photo B. Remove them both and put them back in reverse order? It’ll still choose the photo you DON’T want and make it the thumbnail

    It’s like it reads your mind, then decides to screw with you.

    Hey Manntis,
    your theme function dp_attachment_image fails to state which order to use.
    try adding an order by clause to your array

    'post_type' => 'attachment',
    		'numberposts' => 1,
    		'post_mime_type' => 'image',
    'order_by' => 'menu_order',
    'order' => 'ASC')

    HTH

    that appears to have worked! many thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Post thumbnail fristrations’ is closed to new replies.