<?php if (!defined('ABSPATH')) exit; 
if(count($templates)):  ?>
<?php
    $UrlPageNBD = getUrlPageNBD('create');
    foreach ($templates as $key => $temp): 
    $link_template = add_query_arg(array(
        'product_id' => $temp['product_id'],
        'variation_id' => $temp['variation_id'],
        'reference'  =>  $temp['folder']
    ), $UrlPageNBD);       
    $gallery_type = 1;
?>
    <div class="nbdesigner-item" data-id="<?php echo esc_attr($temp['tid']); ?>" data-img="<?php echo esc_attr($temp['image']); ?>" data-title="<?php echo esc_attr($temp['title']); ?>">
        <div class="nbd-gallery-item">
            <div class="nbd-gallery-item-inner">
                <a href="<?php echo esc_attr($link_template); ?>" onclick="previewTempalte(event, <?php echo esc_attr($temp['tid']); ?>)">
                    <img src="<?php echo esc_url($temp['image']); ?>" class="nbdesigner-img"/>
                </a>
            </div>
        </div>
    </div>
    <?php endforeach;
    else: ?>    
    <?php //todo something ?>
<?php endif;