add 'first' and 'last' context vars to templates for image view