In Short: I am creating a WP function that will echo a image url based on the following conditions
in english here’s how the conditional should work
if custom taxonomy terms exist then build the img src url from custom taxonomy terms
elseif custom taxonomy does not exist - then display default image
else custom taxonomy exists but the image is not avail. in external url then display default image
here’s what I’ve got so far, I cant get step 3 to work
I did find this solution:
[php]
function is_200(){
$urlimage = ‘http://images.mysite.com/auto/mercedes-car.jpg’;
if(@getimagesize($urlimage) !== false)
{
echo “HAVE image”;
}
else
{
echo “Nop.”;
}
}[/php]
but I couldent get it to work with my function, below
[php]function cib_auto_thumbnail($width,$height) {
$timurl = “http://www.mywebsite.com/wp-content/plugins/timthumb.php?src=”;
$thumburl =“http://images.mywebsite.com/auto/”;
$defaultthumb =“http://images.mywebsite.com/auto/cib.jpg”;
$thumburl2 =".jpg";
$timmake =""; $i = 1; foreach((get_the_terms( $post->ID, ‘OriginalTag’ )) as $timmakecat) {if ($timmakecat->parent == 0) {$timmake .= $timmakecat->name; if($i == 1) break;}} ;
$timmodel =""; $i = 1; foreach((get_the_terms( $post->ID, ‘OriginalTag’ )) as $timmodelcat) {if ($timmodelcat->parent |= 0) {$timmodel .= $timmodelcat->name; if($i == 1) break;}} ;
if (empty($timmake) || empty($timmodel)) {
echo '<img src="' . $timurl . $defaultthumb .'" / >';
// if no make or model i.e. custom taxonomy is blank; then get default image
// problem is a custom taxonomy can be created by the author - but the corrosponding image might not exist in the external file folder, hence I need the additional elseif to check for that
} else {
echo ‘<img src="’ . $timurl . $thumburl . $timmake . ‘-’ . $timmodel . $thumburl2 .’" / >’;
// else get image from make and model custom taxonomy and create image url
} [/php]
**OriginalTags is the name of my custom taxonomy terms
*** Every image in the external location is named appropriately as: make-model.jpg i.e. $timmake-$timmodel.jpg