+2  A: 

Assuming you're echoing it to the page for some sort of copy/paste instructions:

<div class="excerpt">
<?php
$key = 'thumb-url';
$themeta = get_post_meta($post->ID, $key, TRUE);
if($themeta != '') {
    echo htmlspecialchars('<img alt="<?php the_title() ?>" src="<?php if ( function_exists(\'get_custom_field_value\') ){ get_custom_field_value(\'thumb-url\', true); } ?>" align="absmiddle" height="62" width="62" class="writtenpostimg" />');
}

?>
Jage
works. thank you Jage
chris m
A: 

This escapes the code... The other comment actually prints out "<img...>", so it depends on what you're trying to do.

You can remove the PHP tags and use conditional expressions:

<div class="excerpt">
<?php
$key = 'thumb-url';
$themeta = get_post_meta($post->ID, $key, TRUE);
if($themeta != '') {
echo '<img alt="'.the_title().'" src="'.(function_exists('get_custom_field_value')?get_custom_field_value('thumb-url', true):'').'" align="absmiddle" height="62" width="62" class="writtenpostimg" />';

It might be easier to understand if you actually use a variable for it:

$url = ""
if(function_exists('get_custom_field_value'))
  $url = get_custom_field_value('thumb-url', true);
echo '<img alt="'.the_title().'" src="'.$url.'" align="absmiddle" height="62" width="62" class="writtenpostimg" />';
bradlis7