<?php /* NOTE: GENERATED BY GULP !!! */ ?><?php
$b = "flo-block-related-items"; // To be used inside HTML

// Start: Class name automation
  $b__for_css = ".".$b; // To be used inside CSS
  $b__uniq = $b."--".mt_rand(1, 999); // To be used inside HTML
  $b__uniq_for_css = ".".$b__uniq; // To be used inside CSS
// End: Class name automation

$elements_color = flo_data($data, "elements_color");

$title = flo_data($data, "title");
$title_font = flo_data($data, "title_font");

$display_category = flo_data($data, "display_category");
$category_font = flo_data($data, "category_font");
$item_title_font = flo_data($data, "item_title_font");
?>

<?php $__env->startSection('block_content'); ?>
  <?php echo $__env->make('core.style', [
    "breakpoint__general" => "

    ".
    flo_render_typography_styles(
    $b__uniq_for_css." ".$b__for_css."__title",
    $title_font
    )
    ."

    ".
    flo_render_typography_styles(
    $b__uniq_for_css." ".$b__for_css."__item-category",
    $category_font
    )
    ."

    ".
    flo_render_typography_styles(
    $b__uniq_for_css." ".$b__for_css."__item-title",
    $item_title_font
    )
    ."

    ".$b__uniq_for_css." {
      color: ".$elements_color.";
    }

    "
  ], array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
  <div class="<?php echo $b; ?> <?php echo $b__uniq; ?>">
    <?php if($title): ?>
      <h3 class="<?php echo $b; ?>__title">
        <?php echo $title; ?>

      </h3>
    <?php endif; ?>

    <?php /* START: ITEMS */ ?>
      <?php
        $post_type = get_post_type($post->ID);

        if($post_type == 'gallery'){
          $taxonomy = 'gallery-category';
        }else{
          $taxonomy = 'category';
        }

        $related_posts__query = similar_query($post->ID, $taxonomy, 3);

        if( is_object($related_posts__query) && $related_posts__query->have_posts()){
      ?>
        <div class="<?php echo $b; ?>__items">
          <?php while($related_posts__query->have_posts()): ?>
            <?php
              $related_posts__query->the_post();

              if(has_post_thumbnail($related_posts__query->post->ID)){
                $thumb_url = get_the_post_thumbnail_url($related_posts__query->post->ID, "full");

                $image_id = get_post_thumbnail_id($related_posts__query->post->ID);
                $image_alt = get_post_meta($image_id, '_wp_attachment_image_alt', TRUE);

                $thumb_url = aq_resize( $thumb_url, $width = 550, $height = 360, $crop = true, $single = true, $upscale = false );

              }else{
                $thumb_url = get_template_directory_uri().'/theme-files/public/img/no-image.jpg';

                $image_alt = '';
              }

              $category = false;
              if ($taxonomy) {
                if ($taxonomy == 'gallery-category') {
                  $category = flo_get_the_first_term( $id = $post->ID, $taxonomy = $taxonomy, $before = '', $sep = '', $after = '', $linked_terms = false ); // Need Name Only
                } else {
                  $category = get_the_category();
                  $category = $category[0]->cat_name;
                }
              }
            ?>
              <a href="<?php echo the_permalink(); ?>" class="<?php echo $b; ?>__item">
                <span class="<?php echo $b; ?>__item-featured-image">
                  <img class="<?php echo $b; ?>__featured-image"
                    src="<?php echo $thumb_url; ?>"
                    alt="<?php echo $image_alt; ?>"
                  />
                </span>
                <span class="<?php echo $b; ?>__item-text-area">
                  <h2 class="<?php echo $b; ?>__item-title">
                    <?php echo the_title(); ?>

                  </h2>
                  <?php if($display_category && $category): ?>
                    <h4 class="<?php echo $b; ?>__item-category">
                      <?php echo $category; ?>

                    </h4>
                  <?php endif; ?>
                </span>
              </a>
            <?php wp_reset_postdata(); ?>
          <?php endwhile; ?>
        </div>
      <?php } ?>
    <?php /* END: ITEMS */ ?>

  </div>
<?php $__env->stopSection(true); ?>

<?php echo $__env->make('layout.block', [
  "block_classes" => "", // Will be added to main block div. e.g. flo-block--full-width
  // "data_onready" => "block_name" // Specify a function (see _blank.js on how to define) that will be executed on document ready.
], array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>