mirror of
https://github.com/narrrl/holy-flavor-rater.git
synced 2026-11-03 16:41:27 +01:00
main image selections
This commit is contained in:
1 parent
caf3830d72
commit
466d0a0f9f
7 files changed
+153
-80
No files matched your search
@@ -1,5 +1,7 @@
|
||||
from typing import Any
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def absolute_image_url(serializer: Any, image_field: Any) -> str | None:
|
||||
if not image_field:
|
||||
@@ -8,3 +10,14 @@ def absolute_image_url(serializer: Any, image_field: Any) -> str | None:
|
||||
if request:
|
||||
return request.build_absolute_uri(image_field.url)
|
||||
return image_field.url
|
||||
|
||||
|
||||
def absolute_media_url(serializer: Any, rel_path: str | None) -> str | None:
|
||||
if not rel_path:
|
||||
return None
|
||||
media_url = settings.MEDIA_URL.rstrip("/") + "/"
|
||||
url = media_url + rel_path.lstrip("/")
|
||||
request = serializer.context.get("request")
|
||||
if request:
|
||||
return request.build_absolute_uri(url)
|
||||
return url
|
||||
Reference in new issue
Block a user