Jump to content

[SOLVED] use a different file when the image is unavailable


akreation

Recommended Posts

How do I replace, or use a different "image unavailable" file when the image is unavailable?

Example::
If image1.jpg is unavailable the use image2.jpg

The code below is the image that is unavailable sometimes, because all records do not have images.
[code]
<img src="/scripts/phpThumb/phpThumb.php?src=/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>2.jpg&w=150&h=150" border="0">
[/code]

Hope this is clear enough, thanks in advance, and forgive the newbe.
Link to comment
Share on other sites

Thanks SA, thats what i need, just haing a little trouble with my code. I tried the ones below with no luck.

[code]
<?php
$path = "/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>1.jpg";
$path = (file_exists($path)) ? $path : "/images/whowont_logo.jpg";
echo "<img src='$path' alt='My Image' />";
?>
[/code]
[code]
<a href="/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>1.jpg">
<img src="<?php $path = "/scripts/phpThumb/phpThumb.php?src=/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>1.jpg&w=150&h=150";
$path = (file_exists($path)) ? $path : "/images/whowont_logo.jpg";
echo "<img src='$path' alt='Legendary Place Image One' />";
?></a>
[/code]
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.