WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Post Thumbnails
[resolved] Plugin not working on upgrade to 3.1 (12 posts)

  1. allyweb
    Member
    Posted 3 years ago #

    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

  2. Rob Cubbon
    Member
    Posted 3 years ago #

    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!

  3. Rob Cubbon
    Member
    Posted 3 years ago #

    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?

  4. Rob Cubbon
    Member
    Posted 3 years ago #

    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.

  5. Rian Rietveld
    Member
    Posted 3 years ago #

    same here :(

  6. Ken Dirschl
    Member
    Posted 3 years ago #

    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.

  7. Rian Rietveld
    Member
    Posted 3 years ago #

    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"/>';
    ?>
  8. lordarkad
    Member
    Posted 3 years ago #

    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.

  9. skarck
    Member
    Posted 3 years ago #

    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?

  10. Chris Scott
    Member
    Plugin Author

    Posted 3 years ago #

    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'
    		)
    	);
    }
  11. kelune
    Member
    Posted 3 years ago #

    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"/>';
    ?>
  12. Curtiss Grymala
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic