bsw/jbe@4: local image_type = param.get("image_type") bsw/jbe@4: local record = MemberImage:by_pk(param.get_id(), image_type, true) bsw/jbe@4: bsw/jbe@4: if record == nil then bsw@1145: local default_file = ({ avatar = "avatar.jpg", photo = nil })[image_type] or 'icons/16/lightning.png' bsw@1145: request.redirect{ static = default_file } bsw@1145: return bsw/jbe@4: end bsw/jbe@4: bsw/jbe@52: assert(record.content_type, "No content-type set for image.") bsw/jbe@52: bsw/jbe@52: slot.set_layout(nil, record.content_type) bsw/jbe@4: bsw/jbe@4: if record then bsw@1145: request.add_header("Cache-Control", "max-age=300"); -- let the client cache the image for 5 minutes bsw/jbe@52: slot.put_into("data", record.data) bsw/jbe@4: end