Checking if there is an Image inserted – if not don’t display anything

Try the following code:

<div class="item active <?php
    // If image URL is empty, echo "hidden"
    echo (get_theme_mod('slider_one', '') == '' ? 'hidden' : '');
?>">
    <img class="img-responsive" src="https://wordpress.stackexchange.com/questions/217340/<?php echo esc_url( get_theme_mod("slider_one', '' ) ); ?>" alt="Slider 1">
</div>

Then use the following CSS:

.hidden { display: none }

What this will do is:

  • If no image is selected (i.e. get_theme_mod(...) == '')
  • Echo class hidden
  • The CSS will hide all elements with .hidden