Reputation: 1087
Is there a filter of some sort that can add an image if there is no featured image present when using the Elementor pro "post" element. Because the title goes up if there is no image placed and it breaks the sites display
I want to add a placeholder image like this one below when no featured image is available:
Upvotes: 0
Views: 14218
Reputation: 811
You can add this filter to you theme functions.php
:
function mlnc_filter_post_thumbnail_html( $image_placeholder ) {
// If there is no post thumbnail,
// Return a default image
if ( '' == $image_placeholder ) {
return '<img src="' . get_template_directory_uri() . '/images/default-thumbnail.png"/>';
}
// Else, return the post thumbnail
return $image_placeholder;
}
add_filter( 'post_thumbnail_html', 'mlnc_filter_post_thumbnail_html' );
Another way is to go where the image is outputting and add an If statement like below:
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
<img src="<?php bloginfo('template_directory'); ?>/images/default-image.jpg"/>
<?php } ?>
Upvotes: 0