I have the following code in attempt to check for an image before an echo. The reason for doing so is if there is no image it won't echo anything and there won't be a missing image link put in a post that has no image. However this code does not work and when no image exists a missing image icon is added. Is there another way to solve this.
<?php $image = wp_get_attachment_image_src(get_field('post_image1'), 'thumbnail'); ?>
<img src="<?php if($image !=false) echo $image[0]; ?>" alt="<?php get_the_title(get_field('post_image1')) ?>" />
<?php $image = wp_get_attachment_image_src(get_field('post_image2'), 'thumbnail'); ?>
<img src="<?php if($image !=false) echo $image[0]; ?>" alt="<?php get_the_title(get_field('post_image2')) ?>" />