<?php
if (isset($block['data']['preview_image_help'])) {    /* rendering in inserter preview  */
    echo '<img src="' . $block['data']['preview_image_help'] . '" style="width:100%; height:auto;">';
} else {
    $columns    = get_field('ftm_list_icon_columns');
    $iconColor  = (!empty(get_field('ftm_list_icon_icon_color'))) ? get_field('ftm_list_icon_icon_color') : '';
    $iconType   = get_field('ftm_list_icon_type');
?>
    <ul id="ftm-list-icon" class="columns-<?php echo $columns; ?>">
        <?php
        if (have_rows('ftm_list_icon_items')) :
            while (have_rows('ftm_list_icon_items')) : the_row();
                $listItem = get_sub_field('ftm_list_icon_item');
                $listLink = get_sub_field('ftm_list_icon_link_target');
                $content  = $listItem;
                if (!empty($listLink)) {
                    $content = '<a href="' . $listLink . '">' . $listItem . '</a>';
                }
        ?>
                <li>
                    <i class="icon-<?php echo $iconType; ?>" style="color:<?php echo $iconColor; ?>"></i>
                    <?php echo $content; ?>
                </li>
        <?php
            endwhile;
        else :
        // no rows found
        endif;
        ?>
    </ul>
    <?php
    if (!empty($iconColor)) {
    ?>
        <style>
            .icon-<?php echo $iconType; ?>:before {
                content: attr(style);
            }
        </style>
<?php
    }
}
?>