In the first link, the code in the responses all build off of the last, so the code you want will be the last posted:
`
<?php }
if (hasNextImage()) { ?>
<?php printCustomSizedImageMaxHeight(400); ?>
else { ?>
<?php printCustomSizedImageMaxHeight(400); ?>
<?php } ?>
`
However, the code exactly how it is is still not completely correct; it needs to have the change posted by acrylian to work (`else { ?>` needs to be `<?php } else { ?>`).
There is also one other minor change that should be made - `printCustomSizedImageMaxHeight` is considered deprecated, so you should replace `printCustomSizedImageMaxHeight` with `printCustomSizedImageMaxSpace` (see http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functionprintCustomSizedImageMaxHeight in the functions guide for details).