Help with PHP for loading an image.

Join Discord

Atomicide

Golden Oldie
Golden Oldie
Jul 4, 2003
1,029
3
195
Ok, im gonna have to basically explain the situation before I go ahead and ask for an answer.

Im currently editing a skin for one of my websites, I did not make the skin myself and im certainly no master at PHP codes.
The site has a function which takes an image and adds it to an image glider, it also produces a thumbnail of the image.

I have edited parts of the skin so that the relevant image loads for each article when the article is veiwed.

The issue I am having is that when im making video posts there are no images to insert, so the image that should load at the top of the article doesnt show. I would prefer to omit the images from video posts anyway because it looks untidy.

Currently
Code:
<div class="data"><img src="<?php echo ($feature); ?>" width="620" height="220" alt="<?php the_title(); ?>"/></div>

is what is used to load the images. What I need is some way to check the the $feature variable can be read and if something exists for it, and if so go ahead and include the full code in the page, or if not, omit it entirely.

I have tried using the file_exists function, but unfortunately due to some of PHP functions being disabled on my host it doesnt work and always returns false.

If anyone has any idea what im talking about or asking for I would be extremely grateful. Just incase it matters, the $function variable currently holds the full url to the folder where the image in question is stored.
 

Ven_

LOMCN n00bie
May 24, 2009
8
0
12
few different ways to do it, easiest would be a case statement with each feature, along theselines

Code:
$feature = "message";

switch ($feature) {
    case message:
        echo "<div class=\"data\"><img src=\" message\" width=\"620\" height=\"220\" alt=".the_title()."/></div>";
        break;
    case video:
        echo "<div class=\"data\"><img src=\" video\" width=\"620\" height=\"220\" alt=".the_title()."/></div>";
        break;
  default: echo "<div class=\"data\"><width=\"620\" height=\"220\" alt=".the_title()."/></div>"; 
 break;
}



didnt test or anything but should be ok