Support

Account

Home Forums General Issues onerror on img src?

Solving

onerror on img src?

  • <img src="<?php echo $image[0]; ?>" onError="this.onerror=null;this.src='errorpicture.jpg';" width="<?php echo $image[1]; ?>" height="<?php echo $image[2];?>" class="mbottom0">
    

    this won’t work, any idea how to show a error image when the image src is empty?

  • Try something like:

    if($image){
        ?><img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2];?>" class="mbottom0"><?php
    } else { 
        ?><img src="errorpicture.jpg" class="mbottom0"><?php
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.