<div class="col-8">
<?php foreach( $mainpost as $i => $post ): if ($i == 0): ?>
<?php the_post_thumbnail(); break; ?>
<?php endif; endforeach; ?>
</div>
<div class="col-4">
<div class="row">
<?php foreach( $mainpost as $i => $post ): if ($i > 0):?>
<div class="col-12">
<?php the_post_thumbnail(); ?>
</div>
<?php endif; endforeach; ?>
</div>
</div>
$('figure a').attr('data-attribute', 'ok');