| 1 |
<?php |
| 2 |
$id = wp_unique_id( "bBlocksImageGallery-" ); |
| 3 |
$planClass = BBlocks\Inc\Utils::isPro() ? 'pro' : 'free'; |
| 4 |
|
| 5 |
use BBlocks\Inc\GetCSS as GetCSS; |
| 6 |
|
| 7 |
// Generate Styles |
| 8 |
if( !function_exists( 'bBlocksImageGalleryStyle' ) ) { |
| 9 |
function bBlocksImageGalleryStyle($attributes, $id){ |
| 10 |
extract( $attributes ); |
| 11 |
|
| 12 |
$imgShadow = GetCSS::getShadowCSS( $imgShadow, 'text' ); |
| 13 |
$imgPaddingH = $imgPadding['horizontal'] ?? '0px'; |
| 14 |
$imgPaddingV = $imgPadding['vertical'] ?? '0px'; |
| 15 |
|
| 16 |
$imgLinkSl = "#$id .imgGalleryWrapper .imgGalleryImgLink"; |
| 17 |
|
| 18 |
$imageGalleryStyle = new BBlocksStyleGenerator(); |
| 19 |
$imageGalleryStyle::addStyle( "$imgLinkSl .imgGalleryImg", [ |
| 20 |
'padding' => GetCSS::getSpaceCSS( $imgPadding ), |
| 21 |
GetCSS::getBorderCSS( $imgBorder ) => '', |
| 22 |
'filter' => "drop-shadow( $imgShadow )" |
| 23 |
] ); |
| 24 |
$imageGalleryStyle::addStyle( "$imgLinkSl .imgGalleryImgCaption", [ |
| 25 |
'text-align' => $capAlign, |
| 26 |
'color' => $capColor, |
| 27 |
'margin' => GetCSS::getSpaceCSS( $imgPadding ), |
| 28 |
'width' => "calc( ( 100% - 10px ) - ( $imgPaddingH * 2 ) )", |
| 29 |
'height' => "calc( ( 100% - 10px ) - ( $imgPaddingV * 2 ) )", |
| 30 |
'border-radius' => $imgBorder['radius'] ?? '0px' |
| 31 |
] ); |
| 32 |
|
| 33 |
return GetCSS::getTypoCSS( '', $capTitleTypo )['googleFontLink'] . |
| 34 |
GetCSS::getTypoCSS( '', $capDescTypo )['googleFontLink'] . |
| 35 |
GetCSS::getTypoCSS( "$imgLinkSl .imgGalleryImgCaption h4", $capTitleTypo )['styles'] . |
| 36 |
GetCSS::getTypoCSS( "$imgLinkSl .imgGalleryImgCaption p", $capDescTypo )['styles'] . |
| 37 |
$imageGalleryStyle::renderStyle(); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
extract( $attributes ); |
| 42 |
?> |
| 43 |
<div |
| 44 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 45 |
<?php echo get_block_wrapper_attributes( [ 'class' => $planClass ] ); ?> |
| 46 |
id='<?php echo esc_attr( $id ); ?>' |
| 47 |
> |
| 48 |
<style><?php echo esc_html( bBlocksImageGalleryStyle( $attributes, $id ) ); ?></style> |
| 49 |
|
| 50 |
<div class='imgGalleryWrapper columns-<?php echo esc_attr( $columns['desktop'] ); ?> columns-tablet-<?php echo esc_attr( $columns['tablet'] ); ?> columns-mobile-<?php echo esc_attr( $columns['mobile'] ); ?>'> |
| 51 |
<?php foreach ( $images as $image ) { |
| 52 |
$imgUrl = $image['url']; |
| 53 |
$imgUrlLarge = !empty( $image['sizes']['large']['url'] ) ? $image['sizes']['large']['url'] : $imgUrl; |
| 54 |
$imgAlt = $image['alt'] ? $image['alt'] : $image['title']; ?> |
| 55 |
|
| 56 |
<a class='imgGalleryImgLink' |
| 57 |
<?php if( $isCap ){}else{ ?> |
| 58 |
href='#' |
| 59 |
data-fancybox='imgGalleryPreviewBtn' |
| 60 |
data-src='<?php echo esc_url( $imgUrl ); ?>' |
| 61 |
data-srcset='<?php echo esc_url( $imgUrlLarge ); ?> 576w, <?php echo esc_url( $imgUrl ); ?> 1024w' |
| 62 |
data-sizes='( max-width: 640px ) 640px, 1024px' |
| 63 |
data-caption='<?php echo wp_kses_post( $image['caption'] ); ?>' |
| 64 |
<?php } ?>> |
| 65 |
|
| 66 |
<img src='<?php echo esc_url( $imgUrl ); ?>' alt='<?php echo esc_html( $imgAlt ); ?>' class='imgGalleryImg' /> |
| 67 |
|
| 68 |
<?php if( $isCap && $isPreview ){ ?> |
| 69 |
<div class='imgGalleryImgCaption'> |
| 70 |
<div class='captionContent'> |
| 71 |
<?php echo !empty( $imgAlt ) ? "<h4>". wp_kses_post( $image['caption'] ) ."</h4>" : '' ; ?> |
| 72 |
<?php echo !empty( $image['description'] ) ? "<p>". wp_kses_post( $image['description'] ) ."</p>" : '' ; ?> |
| 73 |
|
| 74 |
<?php if( $isPreview ){ ?> |
| 75 |
<button class='imgGalleryPreviewBtn' |
| 76 |
data-fancybox='imgGalleryPreviewBtn' |
| 77 |
data-src='<?php echo esc_url( $imgUrl ); ?>' |
| 78 |
data-srcset='<?php echo esc_url( $imgUrlLarge ); ?> 576w, <?php echo esc_url( $imgUrl ); ?> 1024w' |
| 79 |
data-sizes='( max-width: 640px ) 640px, 1024px' |
| 80 |
data-caption='<?php echo wp_kses_post( $image['caption'] ); ?>'> |
| 81 |
<i class='fa fa-eye'></i><?php echo esc_html__( 'Preview', 'b-blocks' ); ?> |
| 82 |
</button> |
| 83 |
<?php } ?> |
| 84 |
</div> |
| 85 |
</div> |
| 86 |
<?php } ?> <!-- Image Gallery Caption --> |
| 87 |
</a> <!-- Image Gallery Link --> |
| 88 |
<?php } ?> <!-- Image Gallery Loop --> |
| 89 |
</div> <!-- Image Gallery Wrapper --> |
| 90 |
</div> |
| 91 |
|