• Resolved allyweb

    (@allyweb)


    The code that I have put in my functions.php file is now spitting out errors after upgrading to wordpress 3.1.

    Please help.

    Thank you

Viewing 11 replies - 1 through 11 (of 11 total)
  • It would seem so, allyweb, I had this problem but now I can’t get my whole 3.1 installation working properly after upgrading and the problem started with same error message from functions.php about Multiple Post Thumbnails.

    So if you sort this one out, let me know!

    There’s a potential fix for this posted here http://wordpress.org/support/topic/troubleshooting-wordpress-31-master-list?replies=21 but I don’t understand it:

    The “multiple-post-thumbnails” plug-in breaks the WP-install after doing the upgrade to 3.1. The database doesn’t upgrade.
    Fix: Rename your theme so the default theme will be loaded. Then you can do the database upgrade. Then delete the second post-thumbnail size in your theme’s funcions.php and the call to the function in the theme files. Rename your theme back to the old name and your site should be up and running again. At least this worked for me.

    Surely if you delete the second (and third?) post-thumbnail size in your theme’s functions.php and the call to the function in the theme files then the plug-in is worthless anyway?

    Now I understand, the fix is only for the WP install, the plug-in is still well and truly worthless with WP 3.1 – if anyone comes up with a way of adding more than one featured image (ie an image that has a fixed height and width to a post or page), I’m all ears.

    same here 🙁

    oh fer cryin’ out loud…I just installed it and was wondering why I couldn’t get it to work. sigh. Time to hack the code I guess.

    Quick workaround:

    The admin part works, the output not. After looking at the code of the plugin I decided it was less work to code some output myself.
    The data is stored in the post meta table, so, in the loop…:

    <?php
    $meta_value = get_post_meta( $post->ID, 'post_second-image_thumbnail_id', true);
    $image = wp_get_attachment_image_src( $meta_value, 'full' );
    if ( $image[1] >= 778 ) :
      echo '<img src="' .$image[0]. '"  id='top-image' style="width: 778px; height: '.$image[2].'px"/>';
    endif;
    ?>

    This code is for the second-image I defined in functions.php
    The meta_key for this is: post_second-image_thumbnail_id
    In this case the image is the full image and the width is hardcoded to 778 pixels, you can set these values to your own needs, like:

    <?php
    $meta_value = get_post_meta( $post->ID, 'post_third-image_thumbnail_id', true);
    $image = wp_get_attachment_image_src( $meta_value, 'medium' );
    echo '<img src="' .$image[0]. '" style="width:'.$image[1].'px"; height: '.$image[2].'px"/>';
    ?>

    Hi all,
    I was having a similar problem: after upgrade, I got an error on my function.php new MultiPostThumbnails call.
    I commented that line, deactivate, deleted and reinstall the plugin, and then uncomment my new MultiPostThumbnails call, and that resolve my problem.

    Just for you to know.

    what seems to work as well:

    switch to another theme, then deactivate the plugin.
    run the update.
    activate plugin and switch back to your theme.

    can anyone else confirm this, too?

    Plugin Author Chris Scott

    (@chrisscott)

    To prevent this error on upgrade, wrap the registering of the thumbnails into a check for class_exists. e.g.

    if (class_exists('MultiPostThumbnails')) {
    		new MultiPostThumbnails(array(
    		'label' => 'Secondary Image',
    		'id' => 'secondary-image',
    		'post_type' => 'post'
    		)
    	);
    }

    FYI, I put this in to get it working:

    <?php
    $meta_value = get_post_meta( $post->ID, 'post_second-image_thumbnail_id', true);
    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
    echo '<img src="' .$image[0]. '" style="width:'.$image[1].'px"; height: '.$image[2].'px"/>';
    ?>

    Ah. Chris’ reply explains why I didn’t have any issues using Multiple Post Thumbnails with any of my 3.1 sites. I always use a conditional to check if the class exists before using it anyway (learned that lesson the hard way a few times when I would have the plugin deactivated for some reason and errors would be thrown).

    Thanks for the info, Chris.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: Multiple Post Thumbnails] Plugin not working on upgrade to 3.1’ is closed to new replies.