• Resolved gakdesign

    (@gakdesign)


    I only want to show the <div class=”ngg-imagebrowser-desc”> if there is a description

    so is there a way of doing an ‘if’ on

    <div class=”ngg-imagebrowser-desc”><p><?php echo $image->description ?></p></div>

    something like…

    <?php if($image->description){ ?>
    <div class=”ngg-imagebrowser-desc”><p><?php echo $image->description ?></p></div>
    <?php } else { ?>
    <?php } ?>

    but that actually works?

    https://www.ads-software.com/plugins/nextcellent-gallery-nextgen-legacy/

Viewing 5 replies - 1 through 5 (of 5 total)
  • What happens when you try this?

    Thread Starter gakdesign

    (@gakdesign)

    its shows the

    <div class=”ngg-imagebrowser-desc”><p><?php echo $image->description ?></p></div>

    on all the images if they have a description or not

    im guessing $image->description isnt the right bit to call for the if

    I see now. For some reason, an empty description isn’t actually empty, but it contains a space. So, replace this code:
    <div class="ngg-imagebrowser-desc"><p><?php echo $image->description ?></p></div>
    with this:

    <?php if( $image->description !== ' '){ ?>
    	<div class="ngg-imagebrowser-desc"><p><?php echo $image->description ?></p></div>
    <?php }	?>

    Thread Starter gakdesign

    (@gakdesign)

    AWESOME! that totally works ??
    thanks

    Ben

    Thread Starter gakdesign

    (@gakdesign)

    marked as resolved

    thanks again

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Only show description if there is one’ is closed to new replies.