Opal-Estate-Pro/templates/single-property/preview.php

109 lines
4.1 KiB
PHP
Raw Normal View History

2019-09-10 06:27:33 +02:00
<div class="property-preview">
<?php
global $property;
2019-10-31 08:11:53 +01:00
$galleries = $property->get_gallery();
$thumb_image_size = opalestate_get_option( 'opalestate_thumbnail_size', 'medium' );
$single_image_size = opalestate_get_option( 'featured_image_size', 'full' );
2019-10-31 08:04:01 +01:00
2019-09-10 06:27:33 +02:00
if ( isset( $galleries ) && $galleries ):
?>
<?php
$_id = 'posts-block-' . rand( 1, 9 );
$item = apply_filters( 'opalesate_related_property_column', 1 );
$data = [
'slidesPerView' => 1,
'spaceBetween' => 0,
'loop' => true,
'autoHeight' => 1,
'pagination' => 0,
'effect' => 'slide',
'breakpoints' => [ 1024 => [ "slidesPerView" => 1 ] ],
'thumbnails_nav' => "#swiper-pagination-images",
2020-08-11 08:33:38 +02:00
'navigation' => [
'nextEl' => '.swiper-button-next',
'prevEl' => '.swiper-button-prev',
],
2019-09-10 06:27:33 +02:00
];
$columns = apply_filters( 'opalestate_thumbnail_nav_column', 5 );
$datanav = [
'slidesPerView' => $columns,
'spaceBetween' => 10,
'effect' => 'slide',
'slideToClickedSlide' => true,
'touchRatio' => 0.2,
'loop' => false,
'breakpoints' => [ 1024 => [ "slidesPerView" => 5 ], 768 => [ "slidesPerView" => 3 ] ],
'navigation' => [
'nextEl' => '.swiper-button-next',
'prevEl' => '.swiper-button-prev',
],
];
?>
<div class="opalestate-swiper-wrap">
<div class="opalestate-swiper-play swiper-container"
id="postcarousel-<?php echo esc_attr( $_id ); ?>"
data-swiper="<?php echo esc_attr( wp_json_encode( $data ) ); ?>">
<div class="swiper-wrapper opalestate-gallery">
<?php if ( has_post_thumbnail() ): ?>
<div class="swiper-slide">
2019-10-31 08:11:53 +01:00
<?php the_post_thumbnail( $single_image_size ); ?>
2019-09-10 06:27:33 +02:00
</div>
<?php endif; ?>
<?php if ( isset( $galleries ) && is_array( $galleries ) && $galleries ): ?>
2019-10-31 08:04:01 +01:00
<?php foreach ( $galleries as $key => $src ): ?>
2019-09-10 06:27:33 +02:00
<div class="swiper-slide">
2019-10-31 08:11:53 +01:00
<img src="<?php echo esc_url( wp_get_attachment_image_url( $key, $single_image_size ) ); ?>" alt="gallery">
2019-09-10 06:27:33 +02:00
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
2020-08-11 08:33:38 +02:00
<div class="swiper-button-prev"><i class="fas fa-angle-left"></i></div>
<div class="swiper-button-next"><i class="fas fa-angle-right"></i></div>
2019-09-10 06:27:33 +02:00
</div>
<div class="swiper-pagination-images swiper-container" id="swiper-pagination-images" data-swiper="<?php echo esc_attr( wp_json_encode( $datanav ) ); ?>">
<?php
$count_galleries = 0;
if ( has_post_thumbnail() ) {
$count_galleries = $count_galleries + 1;
}
$count_galleries = $count_galleries + count( $galleries );
?>
<?php if ( $count_galleries > $columns ) : ?>
2019-10-31 08:11:53 +01:00
<div class="swiper-button-prev"><i class="fas fa-angle-left"></i></div>
<div class="swiper-button-next"><i class="fas fa-angle-right"></i></div>
2019-09-10 06:27:33 +02:00
<?php endif; ?>
<div class="swiper-wrapper">
<?php if ( has_post_thumbnail() ):
?>
<div class="swiper-slide">
2019-10-31 08:11:53 +01:00
<div style="background-image:url('<?php echo wp_get_attachment_thumb_url( get_post_thumbnail_id(), $thumb_image_size ); ?>');" class="thumb-nav"></div>
2019-09-10 06:27:33 +02:00
</div>
<?php endif; ?>
<?php if ( isset( $galleries ) && is_array( $galleries ) && $galleries ): ?>
<?php foreach ( $galleries as $key => $src ): ?>
<div class="swiper-slide">
2019-10-31 08:11:53 +01:00
<div style="background-image:url('<?php echo wp_get_attachment_image_url( $key, $thumb_image_size ); ?>');" class="thumb-nav"></div>
2019-09-10 06:27:33 +02:00
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
</div>
<?php else : ?>
<?php if ( has_post_thumbnail() ): ?>
<div class="property-thumbnail">
<?php the_post_thumbnail( 'full' ); ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>