Your code seems to have been cut off at the bottom, so it's hard to see what you need.
A few of points, though:
First, it's always faster to get objects by ID than by name.
$modx->getObject('className', 12);
So if you know the ID of each TV, that will speed things up.
Second, for TVs where you don't need renderOutput(), you don't really need to get the TV object. You can get the TemplateVarResource object directly, which contains the TV's ID, the Resource ID, and the TV Value. It might also be possible (or not) to redo your image TV so that you put the HTML in the output rather than in the TV (i.e., the TV will just contain the URL of the image). If the TV contains the Alt value and size info, that probably won't work, though, but you could still do this for the other TVs.
$tvId = 12;
$resourceId = 33;
$tvr = $modx->getObject('modTemplateVarResource', array ('tmplvarid'=>$tvId, 'contentid'->$resourceId));
$value = $tvr->get('value');
Also, if the return value doesn't have to be an array, it might be faster to just set one string with "\n" for the line breaks.
You might also look into using one or more Tpl chunks with placeholders:
$modx->getChunk('chunkName', $placeholderArray);
getChunk is quite fast and moving the HTML into a chunk will make it *way* easier to maintain.
Finally, it's hard to tell from the code, but a switch statement might be more efficient and easier to read and maintain.
[ed. note: BobRay last edited this post 15 years, 1 month ago.]