<?php
$options = (array)$block['options'];
$items   = (array)$block['items'];
$target  = $options['target_new'] ? '_self' : '_blank';
$circle  = $options['circle_image'] ? 'rounded-circle' : '';

switch ($options['max_rows']) {
    case '0':
    case '1':
        $rows = 'col-lg-12 col-md-12 col-12';
        break;

    case '2':
        $rows = 'col-lg-6 col-md-6 col-12';
        break;

    case '3':
        $rows = 'col-lg-4 col-md-4 col-12';
        break;

    case '4':
        $rows = 'col-lg-3 col-md-3 col-12';
        break;

    case '6':
        $rows = 'col-lg-2 col-md-2 col-12';
        break;

    case '12':
        $rows = 'col-lg-1 col-md-1 col-12';
        break;
}
?>
<div class="widget-list widget-list-media">
    <div class="row clearfix">
        <?php foreach ($items as $item) { ?>
            <div class="<?php echo $rows; ?>">
                <div class="widget-list-media-single text-center">
                    <div class="widget-list-media-single-image">
                        <?php if (!empty($item['link'])) { ?>
                            <a href="<?php echo $item['link']; ?>" title="<?php echo _escape($item['caption']); ?>"
                               target="<?php echo $target; ?>">
                                <img class="img-fluid <?php echo $circle ?>" src="<?php echo $item['image']; ?>"
                                     alt="<?php echo _escape($item['caption']); ?>">
                            </a>
                        <?php } else { ?>
                            <img class="img-fluid <?php echo $circle ?>" src="<?php echo $item['image']; ?>"
                                 alt="<?php echo _escape($item['caption']); ?>">
                        <?php } ?>
                    </div>
                    <?php if (!empty($item['caption'])) { ?>
                        <h4 class="pi-ellipsis pi-ellipsis-1">
                            <?php if (!empty($item['link'])) { ?>
                                <a href="<?php echo $item['link']; ?>"
                                   title="<?php echo _escape($item['caption']); ?>" target="<?php echo $target; ?>">
                                    <?php echo _escape($item['caption']); ?>
                                </a>
                            <?php } else { ?>
                                <?php echo _escape($item['caption']); ?>
                            <?php } ?>
                        </h4>
                    <?php } ?>
                    <?php if (!empty($item['summary'])) { ?>
                        <div class="widget-list-media-single-summery clearfix">
                            <?php echo $item['summary']; ?>
                        </div>
                    <?php } ?>
                </div>
            </div>
        <?php } ?>
    </div>
</div>