protected function render()
{
$settings = $this->get_settings();
if (empty($settings['image']['url'])) {
return;
}
$has_caption = !empty($settings['caption']);
$this->add_render_attribute('wrapper', 'class', 'elementor-image');
if (!empty($settings['shape'])) {
$this->add_render_attribute('wrapper', 'class', 'elementor-image-shape-' . $settings['shape']);
}
$link = $this->get_link_url($settings);
if ($link) {
$this->add_render_attribute('link', 'href', $link['url']);
if (!empty($link['is_external'])) {
$this->add_render_attribute('link', 'target', '_blank');
}
}
?>
<div <?php
echo $this->get_render_attribute_string('wrapper');
?>
>
<?php
if ($has_caption) {
?>
<figure class="wp-caption">
<?php
}
if ($link) {
?>
<a <?php
echo $this->get_render_attribute_string('link');
?>
>
<?php
}
echo Group_Control_Image_Size::get_attachment_image_html($settings);
if ($link) {
?>
</a>
<?php
}
if ($has_caption) {
?>
<figcaption class="widget-image-caption wp-caption-text"><?php
echo $settings['caption'];
?>
</figcaption>
<?php
}
if ($has_caption) {
?>
</figure>
<?php
}
?>
</div>
<?php
}