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@1148: local dynamic = param.get("dynamic") bsw@1148: bsw@1147: local data, content_type bsw@1147: bsw@1147: if record then bsw@1147: data = record.data bsw@1147: assert(record.content_type, "No content-type set for image.") bsw@1147: content_type = record.content_type bsw@1147: bsw@1147: else bsw@1147: local default_file = "avatar.jpg" bsw@1147: content_type = "image/jpeg" bsw@1147: if image_type == "photo" then bsw@1606: default_file = "avatar.jpg" bsw@1147: content_type = "image/png" bsw@1147: end bsw@1147: bsw@1147: local filename = WEBMCP_BASE_PATH .. "static/" .. default_file bsw@1147: bsw@1147: local f = assert(io.open(filename), "Cannot open default image file") bsw@1147: data = f:read("*a") bsw@1147: f:close() bsw@1147: bsw/jbe@4: end bsw/jbe@4: bsw@1148: if not dynamic then bsw@1148: request.allow_caching() bsw@1148: end bsw/jbe@4: bsw@1147: slot.set_layout(nil, content_type) bsw@1147: slot.put_into("data", data)