Jump to content

If Else File Exists Statement


thetechieone

Recommended Posts

I have a wordpress site that I am working on and I have a plugin that allows the user to upload a picture to a business directory.  http://www.bccsf.org/diretorio-de-servicos/.  I am trying to tweak the code to show a default image if an image is not present.  Here is the code I have right now.

 

<?php if (file_exists($entry->getCardImage)) {
	echo $entry->getCardImage();
	} else {
	print '<img src="http://www.villagebaptisthome.org/sites/default/files/images/placeholder.thumbnail.png"/>';
	}
	?>

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/202011-if-else-file-exists-statement/
Share on other sites

Well the problem was, I was getting the default image on all entries.  I have it working now.  Here is the code I used.

 

<?php if ($entry->getCardImage() != null) {
	echo $entry->getCardImage();
	} else {
	print '<img src="http://www.villagebaptisthome.org/sites/default/files/images/placeholder.thumbnail.png"/>';
	}
	?>

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.