Jump to content

Default Image?!?


suess0r

Recommended Posts

Here's some sample code. It is written in long hand for better understanding, but it could be written much simpler depending on your needs.

[code]<?php
$defaultImage = "default.jpg";

$myImage = "somenewimage.jpg";

if (file_exists($myImage)) {
   $img = $myImage;
} else {
   $img = $defaultImage;
}

echo "<img src=\"".$img."\">";
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/33030-default-image/#findComment-153851
Share on other sites

That didn't work that well.. here's what i'm working with.

[quote]<?php

echo '<b><p align="center"><img src="/images/clubs/logos/'.$id.'.jpg" align="center" width="300" height="128"></p>';
?>
[/quote]
right now.. here's my concept

[quote]<?php
$defaultImage = "/images/clubs/logo/default.jpg";

$myImage = "/images/clubs/logos/'.$id.'.jpg";

if (file_exists($myImage)) {
$img = $myImage;
} else {
$img = $defaultImage;
}

echo "<img src=\"".$img."\">";
echo '<b><p align="center"><img src="'.$img.'" align="center" width="300" height="128"></p>';
?>[/quote]
Link to comment
https://forums.phpfreaks.com/topic/33030-default-image/#findComment-153968
Share on other sites

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.