foreach ($posts as $post) {
        /* Image size */
        switch (isset($fields->item_column_size) && !empty($fields->item_column_size) ? $fields->item_column_size : 'grid-md-3') {
            case "grid-md-12":
                //1-col
                $image_dimensions = array(1200, 900);
                break;
            case "grid-md-6":
                //2-col
                $image_dimensions = array(800, 600);
                break;
            default:
                $image_dimensions = array(400, 300);
        }
        /* Image */
        $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), apply_filters('modularity/image/latest/box', municipio_to_aspect_ratio('16:9', $image_dimensions), $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)) {
                $meta_data = json_encode($meta_data);
            }
        } else {
            $meta_data = "";
        }
        ?>
    <div class="<?php 
        echo isset($fields->item_column_size) && !empty($fields->item_column_size) ? $fields->item_column_size : 'grid-md-3';
        ?>
">
            break;
        default:
            include \Modularity\Helper\Wp::getTemplate($module->post_type . '-cards', 'module/modularity-mod-contact', false);
            break;
    }
} else {
    ?>

<div class="<?php 
    echo implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-card'), $module->post_type, $args));
    ?>
" itemscope="person" itemtype="http://schema.org/Organization">

    <?php 
    if (isset($fields->picture) && !empty($fields->picture)) {
        $image = wp_get_attachment_image_src($fields->picture->id, apply_filters('modularity/image/contact', municipio_to_aspect_ratio('16:9', array(400, 400)), $args));
    } else {
        $image = false;
    }
    ?>

    <?php 
    if ($image !== false) {
        ?>
    <img class="box-image" src="<?php 
        echo $image[0];
        ?>
" alt="<?php 
        echo $fields->first_name;
        ?>
 <?php 
<div class="grid">
<?php 
$contacts = $fields->contacts;
foreach ($contacts as $contact) {
    $info = array('image' => null, 'first_name' => null, 'last_name' => null, 'work_title' => null, 'administration_unit' => null, 'email' => null, 'phone' => null, 'address' => null, 'visiting_address' => null, 'opening_hours' => null);
    switch ($contact->acf_fc_layout) {
        case 'custom':
            $info = apply_filters('Modularity/mod-contacts/contact-info', array('image' => $contact->image, 'first_name' => $contact->first_name, 'last_name' => $contact->last_name, 'work_title' => $contact->work_title, 'administration_unit' => $contact->administration_unit, 'email' => strtolower($contact->email), 'phone' => $contact->phone, 'address' => $contact->address, 'visiting_address' => $contact->visiting_address, 'opening_hours' => $contact->opening_hours, 'other' => $contact->other), $contact);
            break;
        case 'user':
            $info = apply_filters('Modularity/mod-contacts/contact-info', array('image' => null, 'first_name' => $contact->user->user_firstname, 'last_name' => $contact->user->user_lastname, 'work_title' => null, 'administration_unit' => null, 'email' => strtolower($contact->user->user_email), 'phone' => null, 'address' => null, 'visiting_address' => null, 'opening_hours' => null), $contact);
            break;
    }
    if (isset($info['image']) && !empty($info['image'])) {
        $image = wp_get_attachment_image_src($info['image']->id, apply_filters('Modularity/image/contact', municipio_to_aspect_ratio('16:9', array(400, 400)), $args));
    } else {
        $image = false;
    }
    ?>

<div class="<?php 
    echo isset($fields->columns) && !empty($fields->columns) ? $fields->columns : 'grid-md-12';
    ?>
">
    <div class="<?php 
    echo implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-card'), $module->post_type, $args));
    ?>
" itemscope itemtype="http://schema.org/Person">
        <?php 
    if ($image !== false) {
        ?>
<?php

$fields = get_fields($module->ID);
$imageSrc = $fields['mod_image_image']['url'];
if ($fields['mod_image_crop'] === true) {
    $imageSrc = wp_get_attachment_image_src($fields['mod_image_image']['ID'], apply_filters('Modularity/image/image', municipio_to_aspect_ratio('16:9', array($fields['mod_image_crop_width'], $fields['mod_image_crop_height']))));
    $imageSrc = $imageSrc[0];
} else {
    $imageSrc = $fields['mod_image_image']['sizes'][$fields['mod_image_size']];
}
$classes = array();
if ($fields['mod_image_responsive'] === true) {
    $classes[] = 'image-responsive';
}
if (!$module->hideTitle) {
    echo '<h2>' . $module->post_title . '</h2>';
}
if (isset($fields['mod_image_link_url']) && strlen($fields['mod_image_link_url']) > 0) {
    echo '<a href="' . $fields['mod_image_link_url'] . '"><img src="' . $imageSrc . '" alt="' . $fields['mod_image_image']['alt'] . '" class="' . implode(' ', apply_filters('', $classes)) . '"></a>';
} else {
    echo '<img src="' . $imageSrc . '" alt="' . $fields['mod_image_image']['alt'] . '" class="' . implode(' ', apply_filters('', $classes)) . '">';
}
        $image_dimensions = array(400, 300);
}
/* Get image */
foreach ($items as $item) {
    $post = $item['page'];
    if (!is_null($item['page'])) {
        setup_postdata($post);
    }
    $permalink = $item['link_type'] == 'internal' ? get_permalink() : $item['link_url'];
    $thumbnail_image = null;
    if ($item['image_display'] == 'custom' || $item['link_type'] == 'external') {
        $thumbnail_image = wp_get_attachment_image_src($item['custom_image']['ID'], apply_filters('Modularity/index/image', municipio_to_aspect_ratio('16:9', $image_dimensions), $args));
    } elseif ($item['image_display'] == 'false') {
        $thumbnail_image = false;
    } else {
        $thumbnail_image = wp_get_attachment_image_src(get_post_thumbnail_id($item['page']->ID), apply_filters('Modularity/index/image', municipio_to_aspect_ratio('16:9', $image_dimensions), $args));
    }
    ?>
    <div class="<?php 
    echo $columnClass;
    ?>
">
        <a href="<?php 
    echo $permalink;
    ?>
" class="<?php 
    echo implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-index'), $module->post_type, $args));
    ?>
" data-equal-item>
            <?php 
    if ($thumbnail_image) {
                $image_dimensions = array(1200, 900);
                break;
            case "grid-md-6":
                //2-col
                $image_dimensions = array(800, 600);
                break;
            default:
                $image_dimensions = array(400, 300);
        }
        /* Image */
        $image = null;
        if ($fields->posts_data_source !== 'input') {
            $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), apply_filters('modularity/image/posts/items', municipio_to_aspect_ratio('16:9', $image_dimensions), $args));
        } else {
            if ($post->image) {
                $image = wp_get_attachment_image_src($post->image->ID, apply_filters('modularity/image/posts/items', municipio_to_aspect_ratio('16:9', $image_dimensions), $args));
            }
        }
        ?>
    <div class="<?php 
        echo $fields->posts_columns;
        ?>
">
        <a href="<?php 
        echo $fields->posts_data_source === 'input' ? $post->permalink : get_permalink($post->ID);
        ?>
" class="<?php 
        echo implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-news'), $module->post_type, $args));
        ?>
" data-equal-item>
    ?>
        <h2><?php 
    echo $module->post_title;
    ?>
</h2>
    <?php 
}
?>

    <ul class="image-gallery grid grid-gallery">
        <?php 
if (isset($fields['mod_gallery_images'])) {
    foreach ($fields['mod_gallery_images'] as $image) {
        ?>
        <?php 
        $thumbnail_image = wp_get_attachment_image_src($image['id'], apply_filters('modularity/image/gallery/thumbnail', municipio_to_aspect_ratio('16:9', array(200, 150)), $args));
        ?>
        <li class="grid-md-3">
            <a class="<?php 
        echo implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-index'), $module->post_type, $args));
        ?>
 lightbox-trigger" href="<?php 
        echo $image['sizes']['large'];
        ?>
" <?php 
        if (isset($image['caption']) && !empty($image['caption']) && !in_array(strtolower($image['caption']), array('caption text'))) {
            ?>
data-caption="<?php 
            echo $image['caption'];
            ?>
"<?php 
        <div class="grid-xs-12">
            <h2><?php 
        echo $module->post_title;
        ?>
</h2>
        </div>
    <?php 
    }
    ?>

    <?php 
    foreach ($news as $item) {
        $item = $item['news_item'];
        ?>
        <?php 
        $thumbnail_image = wp_get_attachment_image_src(get_post_thumbnail_id($item->ID), apply_filters('modularity/image/mainnews', municipio_to_aspect_ratio('16:9', array(500, 250)), $args));
        ?>
        <div class="grid-lg-12">
            <a href="<?php 
        echo get_permalink($item->ID);
        ?>
" class="<?php 
        echo implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-news', 'box-news-horizontal'), $module->post_type, $args));
        ?>
">
                <?php 
        if ($hasImages) {
            ?>
                    <div class="box-image-container">
                        <?php 
            if ($thumbnail_image) {
<?php

$fields = get_fields($module->ID);
// Image
$image = false;
if (isset($fields['placeholder_image']) && !empty($fields['placeholder_image'])) {
    $image = wp_get_attachment_image_src($fields['placeholder_image']['id'], apply_filters('Modularity/slider/image', municipio_to_aspect_ratio('16:9', array(1140, 641)), $args));
}
?>

<div class="<?php 
echo implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-panel', 'embedded-video'), $module->post_type, $args));
?>
">
    <?php 
if (!$module->hideTitle) {
    ?>
    <h4 class="box-title"><?php 
    echo !empty($module->post_title) ? apply_filters('the_title', $module->post_title) : 'Video';
    ?>
</h4>
    <?php 
}
?>

    <?php 
if ($fields['type'] == 'upload') {
    ?>
        <video class="ratio-16-9" poster="<?php 
    echo $image !== false ? $image[0] : '';
    ?>