liquid_feedback_frontend

annotate app/main/member_image/show.lua @ 1147:24787d0d9317

Updated delivery and cache control of member images
author bsw
date Sun Mar 22 17:32:38 2015 +0100 (2015-03-22)
parents 904f6807f7fa
children 8874448bbb7a
rev   line source
bsw/jbe@4 1 local image_type = param.get("image_type")
bsw/jbe@4 2 local record = MemberImage:by_pk(param.get_id(), image_type, true)
bsw/jbe@4 3
bsw@1147 4 local data, content_type
bsw@1147 5
bsw@1147 6 if record then
bsw@1147 7 data = record.data
bsw@1147 8 assert(record.content_type, "No content-type set for image.")
bsw@1147 9 content_type = record.content_type
bsw@1147 10
bsw@1147 11 else
bsw@1147 12 local default_file = "avatar.jpg"
bsw@1147 13 content_type = "image/jpeg"
bsw@1147 14 if image_type == "photo" then
bsw@1147 15 default_file = "icons/16/lightning.png"
bsw@1147 16 content_type = "image/png"
bsw@1147 17 end
bsw@1147 18
bsw@1147 19 local filename = WEBMCP_BASE_PATH .. "static/" .. default_file
bsw@1147 20
bsw@1147 21 local f = assert(io.open(filename), "Cannot open default image file")
bsw@1147 22 data = f:read("*a")
bsw@1147 23 f:close()
bsw@1147 24
bsw/jbe@4 25 end
bsw/jbe@4 26
bsw@1147 27 request.allow_caching()
bsw/jbe@4 28
bsw@1147 29 slot.set_layout(nil, content_type)
bsw@1147 30 slot.put_into("data", data)

Impressum / About Us