function firmasite_replace_gallery_links($content)
{
    global $firmasite_settings, $post;
    if ("gallery" != get_post_format()) {
        return $content;
    }
    $gallery_shortcode = firmasite_extract_from_string('[gallery', ']', $content);
    if (!$gallery_shortcode) {
        if (is_single()) {
            $content = "[gallery]" . $content;
        }
    }
    // clearing inserted attachments
    $content = preg_replace("/<a[^>]+\\><img[^>]+\\><\\/a>/", "", $content);
    return $content;
}
<?php

/**
 * @package firmasite
 */
global $post, $firmasite_settings;
$caption_shortcode = firmasite_extract_from_string('[caption', ']', $post->post_content);
?>
 <article id="post-<?php 
the_ID();
?>
" <?php 
post_class("loop_list format_image");
?>
>
 <div class="panel panel-default">
    <div class="entry-content col-xs-12 col-md-12 fs-content-thumbnail">
		<?php 
if (has_post_thumbnail() && !$caption_shortcode) {
    ?>
          <?php 
    the_post_thumbnail("large");
    ?>
        <?php 
}
?>
    </div>
   <div class="panel-footer">
   	<div class="entry-content">
       	<h4 class="entry-title"><strong><a href="<?php 
the_permalink();