Support » Plugin: Multiple Post Thumbnails » Fallback Images

  • 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/

Viewing 1 replies (of 1 total)
  • 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;
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Fallback Images’ is closed to new replies.