The snippet is not working because I am an idiot

There are some errors in it that are careless. Here is a working version (tested):
<?php
$tv = isset($tv) ? $tv : "sbImage";
$tvVal = $modx->getTemplateVarOutput($tv);
if($tvVal != ''){
$output = '<img class="img_right" src="'.$tvVal[$tv].'" alt=""/>';
return $output;
}
?>
The errors:
1) I had the $tv var as the TV value and it was supposed to be the $val (I changed the $val name to $tvVal to make it more clear).
2) $modx->getTemplateVarOutput($tv) returns an array so you need to access the value with array syntax, so rather than using the simple variable mane $tvVal we need to append the array key, which is the name of the TV
$tvVal[$tv]
You can add as many parameters as you want to add title/alt data. To simply use the path you can just add
title="’.$tvVal[$tv].’" to the output string. You can use some php to isolate the file name using the basename() php function. Here is an example:
<?php
$tv = isset($tv) ? $tv : "sbImage";
$tvVal = $modx->getTemplateVarOutput($tv);
if($tvVal != ''){
$fileName = basename($tvVal[$tv]);
$output = '<img class="img_right" src="'.$tvVal[$tv].'" alt="'.$fileName.'"/>';
return $output;
}
?>