Hiperciencia
Member
Posted 2 years ago #
Does anybody knows if there is a code, that i can use in the template pages, that reads the custom field to show the image and, if the custom field is empty, show a default image?
Today I use:
<img src="<?php $values = get_post_custom_values("ImageDestaque"); echo $values[0]; ?>" alt="" style="border:#000000 1px solid" />
I would like to show a "/blank.gif" in case of an empty custom field "ImageDestaque"
How about:
<?php
if(get_post_custom_values("ImageDestaque")) {
$values = get_post_custom_values("ImageDestaque");
$my_url = $values[0];
}
else $my_url = '/blank.gif';
echo '<img src="<?php echo $my_url;?>" alt="" style="border:#000000 1px solid" />';
?>
Hiperciencia
Member
Posted 2 years ago #
marujobhz
Member
Posted 2 years ago #
hi. i need to instead use a blank.gif, if customfield is empty dont show nothing. because IE display a blank error image (red X). in FF its ok, nothing appears. but in IE this error image appears. thanks!