File: /var/www/html/amberconcept/wp-content/themes/zeen/inc/classes/blocks/class-zeen-block-gallery.php
<?php
/**
* Zeen block gallery
*
* @since 2.5.0
*/
class ZeenBlockGallery extends ZeenBlocks {
/**
* Constructor
*
* @since 1.0.0
*
*/
public function __construct( $args ) {
$this->type = 'gallery';
parent::__construct( $args );
}
/**
* Block output
*
* @since 1.0.0
*
*/
public function output( $echo = true ) {
if ( $this->enabled() != true ) {
return;
}
if ( empty( $echo ) ) {
ob_start();
}
$lightbox = ! empty( $this->args['lightbox'] ) && 'on' == $this->args['lightbox'] ? true : false;
if ( empty( $this->args['only_inner'] ) ) {
$this->opening_wrap();
$this->block_title();
echo '<div class="gallery-block__wrap tipi-flex">';
}
$link_size = 'full';
$fb = get_theme_mod( 'lightbox_choice', 1 ) == 2 ? true : '';
if ( ! empty( $this->args['gallery'] ) ) {
$imgs = explode( ',', $this->args['gallery'] );
$count = count( $imgs );
$height = 293;
$width = 293;
if ( 1 == $count ) {
$height = 900;
$width = 900;
} elseif ( 2 == $count ) {
$height = 585;
$width = 585;
} elseif ( 3 == $count ) {
$height = 390;
$width = 390;
}
if ( ! empty( $fb ) ) {
$link_size = 'zeen-900-900';
}
if ( 1 == $this->args['img_shape'] ) {
$height = 247;
$width = 370;
if ( 1 == $count ) {
$width = 1155;
$height = 770;
} elseif ( 2 == $count ) {
$width = 770;
$height = 513;
}
if ( ! empty( $fb ) ) {
$link_size = 'zeen-1155-770';
}
} elseif ( 3 == $this->args['img_shape'] ) {
$height = 490;
$width = 370;
if ( 1 == $count ) {
$height = 1020;
$width = 770;
} elseif ( 2 == $count ) {
$height = 775;
$width = 585;
}
if ( ! empty( $fb ) ) {
$link_size = 'zeen-770-1020';
}
}
$i = 1;
foreach ( $imgs as $key ) {
echo '<div class="gallery-block__image';
$this->animation_class();
echo '" style="--animation-order:' . (int) $i . '">';
if ( 'on' == $lightbox ) {
$img_link = wp_get_attachment_image_src( $key, $link_size );
echo '<a href="' . esc_url( $img_link[0] ) . '" class="tipi-lightbox">';
}
echo wp_get_attachment_image( $key, 'zeen-' . $width . '-' . $height );
$caption = wp_get_attachment_caption( $key );
if ( ! empty( $caption ) ) {
echo '<span class="caption">' . zeen_sanitize_titles( $caption ) . '</span>';
}
if ( 'on' == $lightbox ) {
echo '</a>';
}
echo '</div>';
$i++;
}
}
if ( empty( $this->args['only_inner'] ) ) {
echo '</div>';
$this->closing_wrap();
}
if ( empty( $echo ) ) {
return ob_get_clean();
}
}
}