Problem solved:
Had to add the same global post after the endif:
<?php endif;
if ( $i != 0 ) : ?>
<?php global $post; ?>
<?php
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );
?>