Is it possible to remove <h2> </h2> if the text is in <h2> </h2>?
This is the php code I am modifying so that the title and description text box appears above the slider. It works fine if the slider has a title and description, but on other pages I just need an image - an empty text box is displayed instead when it reads the tags <h2>
and <br>
.
Anyway, I can do an if. $ item ['itemImageTitle'] and. $ item ['itemTitle'] empty show only the image, if not empty, also show the fields?
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>
+3
source to share
1 answer
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>
+1
source to share