Improve actor icons handling and admin
This commit is contained in:
parent
951c74c40a
commit
f66e3f3995
11 changed files with 172 additions and 25 deletions
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}"
|
Loading…
Add table
Add a link
Reference in a new issue