• Resolved ionutcruso

    (@ionutcruso)


    Hello! I use the code below to show the list of images sources at the end of the post. My problem is the div appear even if there is no image source in the post. What can I do?

    <?php
    		
    		 if( function_exists('isc_list')  ) {?>
    		     <div id="sources_css"> 
    			     <input type="checkbox" id="title1" />
                          <label for="title1"><b>Surse imagini</b></label>
    				         <div class="content">
    				           <p><?php
    
    			                  isc_list();
    			?>
    				        </p>
    			            </div>
    		     </div>
       <?php  }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Tim Crull

    (@galanos)

    Hello @ionutcruso!

    Thank you for reaching out to us. We looked into your problem.
    Please note that in this case isc_list() works just as intended when the post contains no images – it returns no markup. The DIV and its content stems from your part of the code and is output unconditionally.
    Nevertheless, we recommend using PHP’s output buffering functionality to achieve what you are trying to accomplish. This is a short snippet you could try:

    <?php	
    	if(function_exists('isc_list')) {
    		ob_start();
    		isc_list();
    		$isc_list_tempoutput = ob_get_clean();
    		if(!empty($isc_list_tempoutput)) {
    ?>
    		<div id="sources_css"> 
    			<input type="checkbox" id="title1" />
    			<label for="title1"><b>Surse imagini</b></label>
    			<div class="content">
    				<p>
    					<?php echo $isc_list_tempoutput; } ?>
    				</p>
    			</div>
    		</div>
    <?php
    	}
    ?>

    Please test our proposal with care and let us know whether this worked for you.

    Best

    Tim

    Thread Starter ionutcruso

    (@ionutcruso)

    It worked! Thanks!

    Plugin Support Tim Crull

    (@galanos)

    Hello @ionutcruso!

    Great, we are happy to hear that! If you’ve got a minute to spare, would you mind leaving a positive review?

    Best
    Tim

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Check if the post has at least a image source’ is closed to new replies.