Jump to content

How to show static image when there is no dynamic image


parlanchina

Recommended Posts

Hello, I have a script that shows dynamic images, this is the script:

<img src="<?php echo $data['thumbnailUrl'];?>" alt="" border="0" width="122" height="92">

When there is no image - $data['thumbnailUrl'], broken image box is displayed. How can I edit this script so when there is no a dynamic image, a static one will show instead?

THANKS!

Thanks for your reply. This is what I tried but it does not work. Do you know what might be wrong?

 

<img src="<?php  if(is_file($data['thumbnailUrl'])){
<img src="<?php echo $data['thumbnailUrl'];?>" alt="" border="0" width="122" height="92"></a>
}else{
<img src="noimage.jpg" width="168" height="128" alt="" /></a>
}
?>" alt="" border="0" width="122" height="92"></a>

Your code should be

<?php  if(is_file($data['thumbnailUrl'])){ ?>
   <img src="<?php echo $data['thumbnailUrl'];?>" alt="" border="0" width="122" height="92">
<?php }else{ ?>
    <img src="noimage.jpg" width="168" height="128" alt="" />
<?php } ?>

No it does not work but actually when I right-click the code of a listing that does not have image, this is what it comes up- http://imagesus.homeaway.com/mda01/1b79ecc4-46fe-49fe-bb75-ac1ec359a177.1.3. It points to an image but it is broken.

 

When I rightclick a working image (example of working image http://imagesus.homeaway.com/mda01/fb6c745c-a3cb-46c4-972d-4ab934a635ab.1.3) it show image type JPEG and for the broken images it shows image type Not Available. Is it possible to structure the script so if it is not a jpeg, gif or png, it will show noimage?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.