WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Post Thumbnails
Fallback Images (2 posts)

  1. Chris Harrison
    Member
    Posted 1 year ago #

    Code could probably be simplified, but this is how I handled having a fallback image in the event a MultiPostThumbnail wasn't provided:

    <?php
    	if (class_exists('MultiPostThumbnails')) :
    		if ( !has_post_thumbnail() ) : ?>
    			<img src="<?php bloginfo( 'template_directory' ); ?>/i/generic.png" class="attachment-secondary-image" alt="<?php the_title(); ?>" />
    <?php
    		else :
    			MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image', NULL, 'secondary-image');
    		endif;
    	endif;
    ?>

    http://wordpress.org/extend/plugins/multiple-post-thumbnails/

  2. Chris Harrison
    Member
    Posted 1 year ago #

    Sorry, strike that. Code was a little out of whack, before. This works:

    <?php
    if (class_exists('MultiPostThumbnails')) :
    	if ( MultiPostThumbnails::has_post_thumbnail( get_post_type(), 'secondary-image', NULL, 'secondary-image') ) :
    		MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image', NULL, 'secondary-image');
    	else : ?>
    		<img src="<?php bloginfo( 'template_directory' ); ?>/i/generic.png" class="attachment-secondary-image" alt="<?php the_title(); ?>" />
    <?php
    	endif;
    endif;
    ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic