If post has attached image + get_the_image conditional code? (1 post)

  1. deeve
    Posted 3 years ago #

    Have looked all over but not seen a definitive answer to this as yet; I'd been successfully using the get_the_image plugin to retrieve images attached to posts. I now want to apply a conditional If statement to either show the attached image [there is only 1 for each] of a post or if one is not present, to show a generic image. I've tried the has post thumbnail() method & I've tried adapting the get_the_image function but with mixed results but nothing correct as yet. Here's what I have so far:

    <?php if(function_exists('get_the_image')) {
    get_the_image(array('default_size' => 'medium', 'image_scan' => true, 'link_to_post' => false));}
    else {
    echo '<img src="/wp-content/themes/platform/img/nopostimage.png" alt="" title="" />';}?>

    Any suggestions appreciated. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic