change avatar (and other images) to relative path of s3 bucket
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import os
|
||||
|
||||
OSS_BASE_URL = os.getenv("OSS_BASE_URL", "").rstrip("/")
|
||||
|
||||
def get_image_url(path: str) -> str:
|
||||
if not path:
|
||||
return ""
|
||||
# 如果已经是完整 URL (比如 Google 原图),直接返回
|
||||
if path.startswith(("http://", "https://")):
|
||||
return path
|
||||
# 否则拼接 OSS 基础域名
|
||||
return f"{OSS_BASE_URL}/{path}"
|
||||
Reference in New Issue
Block a user