This is the php code I am modifying to have a header and a description text box appear above the slider. It works great if there is a header and description set within the slider, but on other pages I just want the image - instead an empty "text box" is displayed as it reads the <h2>
and <br>
tags.
Is there anyway I can make an if .$item['itemImageTitle'] & .$item['itemTitle'] empty show just the image, if not empty show the boxes too?
css
.nivo-caption h2 {
font-size: xx-large;
color: #fff;
}
.theme-default .nivo-caption {
font-family: inherit;
font-size: 16px;
font-weight: bold;
/* z-index: 20; */
-moz-text-shadow: 1px 1px 0 #000;
-webkit-text-shadow: 1px 1px 0 #000;
text-shadow: 1px 1px 0 #000;
position: absolute;
left: 23px;
bottom: 20px;
background: rgba(58, 88, 129, 0.5);
color: #fff;
width: 95%;
z-index: 8;
padding: 5px 10px;
opacity: 1;
overflow: hidden;
display: none;
-moz-opacity: 1;
filter: alpha(opacity=1);
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
php
<div class="slider-wrapper <?php echo "theme-".$theme_title;?>" id="<?php echo "slider-wrapper-".$bID; ?>">
<div id="<?php echo "nivo-slider-".$bID; ?>" class="nivoSlider" style="width: 100% !important;">
<?php
foreach($items as $item) {
echo (strlen($item['itemUrl'])>1) ? '<a href="'.$item['itemUrl'].'">' : '';
echo '<img src="'.$item['itemImageSrc'].'" alt="'.$item['itemImageAlt'].'" title="<h2>'.$item['itemTitle'].'</h2><br>'.$item['itemImageTitle'].'" data-thumb="'.$item['itemImageSrc'].'" >';
echo (strlen($item['itemUrl'])>1) ? '</a>' : '';
}
?>
</div>
</div>
As you said if .$item['itemImageTitle'] & .$item['itemTitle'] empty show just the image
. You can try this
<div class="slider-wrapper <?php echo "theme-".$theme_title;?>" id="<?php echo "slider-wrapper-".$bID; ?>">
<div id="<?php echo "nivo-slider-".$bID; ?>" class="nivoSlider" style="width: 100% !important;">
<?php
foreach($items as $item) {
echo (strlen($item['itemUrl'])>1) ? '<a href="'.$item['itemUrl'].'">' : '';
$my_title = "";
if(!empty($item['itemImageTitle']) && !empty($item['itemTitle'])){
$my_title = '<h2>'.$item['itemTitle'].'</h2><br>'.$item['itemImageTitle'].'</h2>';
}
echo '<img src="'.$item['itemImageSrc'].'" alt="'.$item['itemImageAlt'].'" title="'.$my_title.'" data-thumb="'.$item['itemImageSrc'].'" >';
echo (strlen($item['itemUrl'])>1) ? '</a>' : '';
}
?>
</div>
</div>