<?php

$output = $el_class = $image = $img_size = $img_link = $img_link_target = $img_link_large = $title = $alignment = $css_animation = $css = '';

extract(shortcode_atts(array(
    'title' => '',
    'image' => $image,
    'img_size'  => 'thumbnail',
    'img_link_large' => false,
    'img_link' => '',
    'img_link_target' => '_self',
    'alignment' => 'left',
    'el_class' => '',
    'css_animation' => '',
    'style' => '',
    'border_color' => '',
    'css' => ''
), $atts));

$style = ($style!='') ? $style : '';
$border_color = ($border_color!='') ? ' vc_box_border_' . $border_color : '';

$img_id = preg_replace('/[^\d]/', '', $image);
$img = wpb_getImageBySize(array( 'attach_id' => $img_id, 'thumb_size' => $img_size, 'class' => $style.$border_color ));
if ( $img == NULL ) $img['thumbnail'] = '<img class="'.$style.$border_color.'" src="'.$this->assetUrl('vc/no_image.png').'" />';//' <small>'.__('This is image placeholder, edit your page to replace it.', 'js_composer').'</small>';

$el_class = $this->getExtraClass($el_class);

$link_to = '';
if ($img_link_large==true) {
    $link_to = wp_get_attachment_image_src( $img_id, 'large');
    $link_to = $link_to[0];
}
else if (!empty($img_link)) {
    $link_to = $img_link;
}
$img_output = $img['thumbnail'];
$image_string = !empty($link_to) ? '<a href="' . esc_url( $link_to ) . '"'.($img_link_target!='_self' ? ' target="' . $img_link_target . '"' : '').'>'.$img_output.'</a>' : $img_output;

$output .= '<div class="yt-vc-single-image yt-vc-element'. $el_class . '">';
$output .= wpb_widget_title( array('title' => $title, 'extraclass' => 'yt-vc-element-heading') );
$output .= $image_string;
$output .= '</div> '.$this->endBlockComment('.wpb_wrapper');

echo $output;