Reputation: 13
I want to hide iframe if there is no $content
present.
<div class="video">
<iframe width="600px" height="400px" src="'.$content.'?autoplay=1" frameborder="0" scrolling="no" allowfullscreen style="visibility:hidden;" onload="this.style.visibility=\'visible\';"></iframe>
</div>
In my case if $content
is not present, iframe loads src="?autoplay=1"
Upvotes: 1
Views: 79
Reputation: 10117
I think this will do the trick:
<?php
// Test if variable is set and has content in it
if( isset($content) && $content != "") {
echo '<div class="video"><iframe width="600px" height="400px" src="'.$content.'?autoplay=1" frameborder="0" scrolling="no" allowfullscreen style="visibility:hidden;" onload="this.style.visibility=\'visible\';"></iframe></div>'
}
?>
This way the iframe will not be printed in the html in case of no content.
Upvotes: 1