I am using the Multipostthumbnails plugin – https://wordpress.org/plugins/multiple-post-thumbnails/
And it has a certain naming convention to it. I know the usual way to output a placeholder if no featured image set, but not with their code?
I obviously want something like –
if ( has_post_thumbnail($post->ID) ){
$image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'news-large');
$image = $image[0];
echo '<img src="'.$image.'" alt="" />';
} else {
$image = get_template_directory_uri() .'/assets/img/placeholders/placeholder.png';
echo '<img src="'.$image.'" alt="" />';
}
But their existing code to show a featured image is –
if (class_exists( 'MultiPostThumbnails' )) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'header-image', NULL, 'header-image-full', array('class' => "custom-header-image") ); endif;
Just cannot see how to adjust this to fit my code at the top?
For Blog Pages –
Standard Code –
if (class_exists( 'MultiPostThumbnails' )) : MultiPostThumbnails::the_post_thumbnail( 'page', 'header-image', get_option('page_for_posts'), 'header-image-full', array('class' => "custom-header-image") ); endif;
My attempt to try and show placeholder –
if ( class_exists( 'MultiPostThumbnails' ) ) {
MultiPostThumbnails::the_post_thumbnail( 'page', 'header-image', get_option('page_for_posts'),
'header-image-full',
array('class' => "custom-header-image") );
} else {
$image = get_template_directory_uri() .'/assets/img/placeholders/header_placeholder.png';
echo '<img src="'.$image.'" alt="" />';
}
Many thanks