I’m having trouble with this code. I’ve got this code checking to see if an image exists, and if it doesnt display a an alternative image. It doesnt seem to be working and I cant seem to figure or why? any suggestions…
Cheers
David
<?php
$file = the_title('','',false);
$imgPath = 'http://emotionaltherapy.flexlab.co.uk/wp-content/themes/default/images/' . $file . '.jpg'; ?>
<?php
if (!file_exists($imgPath)) { ?>
<img src="/wp-content/themes/default/images/<?php the_title(); ?>.jpg" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" />
<?php } else { ?>
<img src="/wp-content/themes/default/images/The Foundation for Emotional Therapy.jpg" alt="Emotional Therapy" title="Emotional Therapy" />
<?php } ?>