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!

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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 } ?>
Edited by Ch0cu3r
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.