ok when you add this below $num = count($slides);
$TV = $modx->getTemplateVar(1,$fields,$docid,$published);
$last = $num-1;
if($TV[value]){$firstimage=$TV['value'];}else{
$firstimage=$path.$slides[$last];
}
then you can use a tv for an start image if tv is empty then no start image but the images from the folder
make shure that you change the 1 in $TV = $modx->getTemplateVar(1,$fields,$docid,$published); to the id of your tv
another option is to change the $firstimage= value to the path of your image. then the above code is not needed
Dimmy