fix: not output thumbnail container if no gallery

parent d6be1ffc
......@@ -27,88 +27,91 @@ $vid_out = ( $vid !='' ) ? '<div class="single-vid">'.apply_filters('the_content
$imgs = get_post_meta($post->ID,$pfx.'image');
$imgs_out = '';
$thumbs_out = '';
$gallery_out = '';
$indicators_out = '';
$img_c = 0;
foreach ( $imgs as $i ) {
if ( $i == '' )
continue;
$id = $i['ID'];
if ( !empty($imgs)) {
$img_c = 0;
foreach ( $imgs as $i ) {
if ( $i == '' )
continue;
$id = $i['ID'];
$thumb_src = wp_get_attachment_image_url($id,'small' );
$thumb_class = ( $img_c == 0 ) ? ' current' : ' ml-3';
$thumbs_out .= '
<button type="button" class="btn p-0 in-thumb'.$thumb_class.'" data-toggle="modal" data-target="#in-gallery">
<img src="'.$thumb_src.'" alt="Thumbnail" />
</button>';
$thumb_src = wp_get_attachment_image_url($id,'small' );
$thumb_class = ( $img_c == 0 ) ? ' current' : ' ml-3';
$thumbs_out .= '
<button type="button" class="btn p-0 in-thumb'.$thumb_class.'" data-toggle="modal" data-target="#in-gallery">
<img src="'.$thumb_src.'" alt="Thumbnail" />
</button>';
$img_src = wp_get_attachment_image_url($id,'large' );
$img_class = ( $img_c == 0 ) ? ' active' : '';
$img_alt = $i['post_title'];
$img_desc = $i['post_content'];
$imgs_out .= '
<div class="carousel-item'.$img_class.'">
<img src="'.$img_src.'" class="d-block w-100" alt="'.$img_alt.'">
<div class="text-dark carousel-caption d-none d-md-block">
<p class="bg-light px-2 font-weight-bold">'.$img_desc.'</p>
$img_src = wp_get_attachment_image_url($id,'large' );
$img_class = ( $img_c == 0 ) ? ' active' : '';
$img_alt = $i['post_title'];
$img_desc = $i['post_content'];
$imgs_out .= '
<div class="carousel-item'.$img_class.'">
<img src="'.$img_src.'" class="d-block w-100" alt="'.$img_alt.'">
<div class="text-dark carousel-caption d-none d-md-block">
<p class="bg-light px-2 font-weight-bold">'.$img_desc.'</p>
</div>
</div>
</div>
';
$indicator_class= ( $img_c == 0 ) ? ' active' : '';
$indicators_out .= '
<li class="bg-dark'.$indicator_class.'" data-target="#in-carousel" data-slide-to="'.$img_c.'"></li>
';
$img_c++;
}
$thumbs_out = '
<div id="entry-gallery" class="container-fluid">
<div class="row">
<div class="col-md-12 p-0">
<div class="slide-wrap">
<button type="button" class=" btn slide-arrow slide-arrow-left text-decoration-none"><i class="fa fa-4x fa-angle-left" aria-hidden="true"></i></button>
<button type="button" class="btn slide-arrow slide-arrow-right text-decoration-none"><i class="fa fa-4x fa-angle-right" aria-hidden="true"></i></button>
<div id="project-imgs-nav" class="slides">'.$thumbs_out.'</div>
';
$indicator_class= ( $img_c == 0 ) ? ' active' : '';
$indicators_out .= '
<li class="bg-dark'.$indicator_class.'" data-target="#in-carousel" data-slide-to="'.$img_c.'"></li>
';
$img_c++;
}
$thumbs_out = '
<div id="entry-gallery" class="container-fluid">
<div class="row">
<div class="col-md-12 p-0">
<div class="slide-wrap">
<button type="button" class=" btn slide-arrow slide-arrow-left text-decoration-none"><i class="fa fa-4x fa-angle-left" aria-hidden="true"></i></button>
<button type="button" class="btn slide-arrow slide-arrow-right text-decoration-none"><i class="fa fa-4x fa-angle-right" aria-hidden="true"></i></button>
<div id="project-imgs-nav" class="slides">'.$thumbs_out.'</div>
</div>
</div>
</div>
</div>
</div>
';
$gallery_out = '
<div id="in-gallery" class="modal fade" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-xl">
<div class="modal-content border-0 rounded-0">
<div class="modal-header border-bottom-0">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body p-0">
<div id="in-carousel" class="carousel slide" data-ride="false">
<ol class="carousel-indicators">
'.$indicators_out.'
</ol>
<div class="carousel-inner">
'.$imgs_out.'
</div>
';
<a class="text-dark btn carousel-control carousel-control-prev" href="#in-carousel" role="button" data-slide="prev">
<i class="fa fa-4x fa-angle-left" aria-hidden="true"></i>
<span class="sr-only">Previous</span>
</a>
<a class="text-dark btn carousel-control carousel-control-next" href="#in-carousel" role="button" data-slide="next">
<i class="fa fa-4x fa-angle-right" aria-hidden="true"></i>
<span class="sr-only">Next</span>
</a>
$gallery_out = '
<div id="in-gallery" class="modal fade" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-xl">
<div class="modal-content border-0 rounded-0">
<div class="modal-header border-bottom-0">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body p-0">
<div id="in-carousel" class="carousel slide" data-ride="false">
<ol class="carousel-indicators">
'.$indicators_out.'
</ol>
<div class="carousel-inner">
'.$imgs_out.'
</div>
<a class="text-dark btn carousel-control carousel-control-prev" href="#in-carousel" role="button" data-slide="prev">
<i class="fa fa-4x fa-angle-left" aria-hidden="true"></i>
<span class="sr-only">Previous</span>
</a>
<a class="text-dark btn carousel-control carousel-control-next" href="#in-carousel" role="button" data-slide="next">
<i class="fa fa-4x fa-angle-right" aria-hidden="true"></i>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
';
';
}
// docs
$docs = get_post_meta($post->ID,$pfx.'doc');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment