Site icon Hip-Hop Website Design and Development

How to add if statement on Cheap WordPress shortcode output

I’m making a shortcode function that collects data from WordPress media library

function byn_recent_resources_shortcode($atts, $content = null) {
    global $post;

    extract(shortcode_atts(array(
        'group'     => 'public',
        'num'     => '1',
        'orderby' => 'post_date',
    ), $atts));

  $args = array(
    'post_status' => 'inherit',
    'posts_per_page' => $num,
    'post_type' => 'attachment',
  );

  $args['tax_query'] = array(
    array(
      'taxonomy' => 'group',
      'terms' => array( $group ),
      'field' => 'slug',
    ),
  );

    $output = '';
    $posts = get_posts($args);

    foreach($posts as $post) {
        setup_postdata($post);
        $output .= '
      <article>
        <div class="thumbnail">

          // IF STATEMENT GOES HERE //

        </div>
      </article>
    ';
    }

    wp_reset_postdata();
    return '<div class="resource-list" id="resource-list"><div class="post-outer-wrap">'. $output .'</div></div>';
}
add_shortcode('byn-recent-resources', 'byn_recent_resources_shortcode');

Inside the <div class="thumbnail"> output, I’m planning to enable <if> statement like so

<?php if ( wp_attachment_is_image( $id ) ) { ?>
  // Do option A
<?php } else { ?>
  // Do option B
<?php } ?>

How do I do that?