liquid_feedback_frontend
view app/main/member_image/show.lua @ 154:6b6c82f9ca9f
speedup member image loading when non set
we can add the location of the default file directy instead of going through another slow request
we can add the location of the default file directy instead of going through another slow request
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Fri Oct 08 15:25:10 2010 +0200 (2010-10-08) |
parents | 034f96181e59 |
children | f52f918b38b8 |
line source
1 local image_type = param.get("image_type")
2 local record = MemberImage:by_pk(param.get_id(), image_type, true)
4 print('Cache-Control: max-age=300'); -- let the client cache the image for 5 minutes
6 if record == nil then
7 local default_file = config.member_image_default_file[image_type]
8 if default_file then
9 print('Location: ' .. encode.url{ static = default_file } .. '\n\n')
10 else
11 print('Location: ' .. encode.url{ static = 'icons/16/lightning.png' } .. '\n\n')
12 end
13 exit()
14 end
16 assert(record.content_type, "No content-type set for image.")
18 slot.set_layout(nil, record.content_type)
20 if record then
21 slot.put_into("data", record.data)
22 end