Improve actor icons handling and admin
This commit is contained in:
20
app/media.py
Normal file
20
app/media.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import base64
|
||||
|
||||
from app.config import BASE_URL
|
||||
|
||||
SUPPORTED_RESIZE = [50, 740]
|
||||
|
||||
|
||||
def proxied_media_url(url: str) -> str:
|
||||
if url.startswith(BASE_URL):
|
||||
return url
|
||||
|
||||
return "/proxy/media/" + base64.urlsafe_b64encode(url.encode()).decode()
|
||||
|
||||
|
||||
def resized_media_url(url: str, size: int) -> str:
|
||||
if size not in SUPPORTED_RESIZE:
|
||||
raise ValueError(f"Unsupported resize {size}")
|
||||
if url.startswith(BASE_URL):
|
||||
return url
|
||||
return proxied_media_url(url) + f"/{size}"
|
Reference in New Issue
Block a user