V Posted June 29, 2010 Share Posted June 29, 2010 I have parts in my script like this <img src="<?php echo $post_thumb; ?>" alt="" ?> the var is just an image url I enter via a "new post" form. Sometimes I won't add images and I get that default broken image icon. Right now I'm using if statements to make it go away if(!empty($post_thumb)){ ...show the image.... I'm just wondering. Instead of using if statements everywhere, is there just some kind of global function that can be used to remove all the broken img icons? Quote Link to comment https://forums.phpfreaks.com/topic/206224-if-no-image-exists/ Share on other sites More sharing options...
MadTechie Posted June 29, 2010 Share Posted June 29, 2010 If your using <img src="<?php echo $post_thumb; ?>" alt="" ?> then I guess not, Of course to could pre parse the output but I wouldn't recommend such a work-around, another option would be to create a "missing-image.jpg" and then set $post_thumb to that for example if(empty($post_thumb){ $post_thumb = "missing-image.jpg"; } Quote Link to comment https://forums.phpfreaks.com/topic/206224-if-no-image-exists/#findComment-1078935 Share on other sites More sharing options...
V Posted June 29, 2010 Author Share Posted June 29, 2010 Thanks MadTechie! Will do! Quote Link to comment https://forums.phpfreaks.com/topic/206224-if-no-image-exists/#findComment-1078952 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.