Check if post has gallery images/media

No Need for SQL queries in the template.

function wpse_72594_get_attachments( $id, $mime="" )
{
    $args = array(
        'post_type' => 'attachment',
        'post_mime_type' => $mime,
        'post_parent' => $id
    ); 
    $attachments = get_posts($args);
    if ($attachments) 
        return $attachments;

    return false;
}

Then call the function like this (300 is the post ID):

  • wpse_72594_get_attachments(300), grabs all attachments
  • wpse_72594_get_attachments(300, 'image' ), only images
  • wpse_72594_get_attachments(300, 'application/pdf' ), only pdf files