Here is how you could do it in a snippet:
<?php
$tv = isset( $tv ) ? $tv : "rechtesBild";
$id = isset( $id )? $id: $modx->documentIdentifier;
$tvValue = $modx -> getTemplateVarOutput( $tv, $id, $published = 1 );
if($tvValue[$tv]){
$output = "<img src=\"$tvValue[$tv]\" alt=\".\" />";
return $output;
}
?>
If you want to use a chunk in order to reuse the same snippet with different output you could do that by changing it like this:
<?php
$chunk = isset($chunk) ? $chunk : '';
$tv = isset( $tv ) ? $tv : "rechtesBild";
$id = isset( $id )? $id: $modx->documentIdentifier;
$tvValue = $modx -> getTemplateVarOutput( $tv, $id, $published = 1 );
if($tvValue[$tv]){
return $modx->getChunk($chunk);
}
?>
You would call it like this:
[[SnippetName? &chunk=`chunkName`]]