if (!$module->hideTitle) {
    ?>
        <div class="grid-xs-12">
            <h2><?php 
    echo $module->post_title;
    ?>
</h2>
        </div>
    <?php 
}
?>

<?php 
$hasImages = false;
foreach ($posts as $post) {
    if (get_thumbnail_source($post->ID) !== false) {
        $hasImages = true;
    }
}
?>

<?php 
foreach ($posts as $post) {
    ?>
    <?php 
    $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), apply_filters('modularity/image/latest/box', municipio_to_aspect_ratio('16:9', array(400, 300)), $args));
    //Make sorted by data avabile
    if (isset($fields->meta_key_output)) {
        $meta_data = get_post_meta($post->ID, $fields->meta_key_output, true);
        //Serialize data if needed
        if (is_array($meta_data) || is_object($meta_data)) {
<?php

$news = get_field('main_news', $module->ID);
if (count($news) > 0) {
    $hasImages = false;
    foreach ($news as $item) {
        $item = $item['news_item'];
        if (get_thumbnail_source($item->ID) !== false) {
            $hasImages = true;
        }
    }
    ?>
<div class="grid">
    <?php 
    if (!$module->hideTitle) {
        ?>
        <div class="grid-xs-12">
            <h2><?php 
        echo $module->post_title;
        ?>
</h2>
        </div>
    <?php 
    }
    ?>

    <?php 
    foreach ($news as $item) {
        $item = $item['news_item'];
        ?>
        <?php