<?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 {
    $linkAttributes = (!empty(get_field('table_cta_link_attributes'))) ? 'rel="' . get_field('table_cta_link_attributes') . '"' : '';
?>
    <table id="ftm_table_cta">
        <tbody>
            <tr>
                <th>Dating App</th>
                <th>Key Facts</th>
                <th>Free Trial Sign Up</th>
            </tr>
            <?php
            if (have_rows('table_cta_sites')) :
                while (have_rows('table_cta_sites')) : the_row();
                    $siteName       = get_sub_field('table_cta_site_name');
                    $siteLogo       = get_sub_field('table_cta_site_logo');
                    $siteFacts      = get_sub_field('table_cta_facts');
                    $linkText       = get_sub_field('table_cta_link_text');
                    $linkTarget     = get_sub_field('table_cta_link_target');
            ?>
                    <tr>
                        <td>
                            <img src="<?php echo $siteLogo["url"]; ?>" class="aligncenter" alt="<?php echo $siteLogo["alt"]; ?>" width="200" height="80">
                            <strong><?php echo $siteName; ?></strong>
                        </td>
                        <td>
                            <?php
                            echo $siteFacts;
                            ?>
                        </td>
                        <td>
                            <a href="<?php echo $linkTarget; ?>" <?php echo $linkAttributes; ?> target="_blank"><?php echo $linkText; ?></a>
                        </td>
                    </tr>
            <?php
                endwhile;
            else :
            // no rows found
            endif;
            ?>
        </tbody>
    </table>
<?php
}
?>