From 9cf22fd440243457f03d14b63bdd1d1901bc0fd8 Mon Sep 17 00:00:00 2001 From: BeritJanssen Date: Tue, 11 Jun 2024 14:15:44 +0200 Subject: [PATCH] include `BASE_URL` in image serialization --- backend/theme/serializers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/theme/serializers.py b/backend/theme/serializers.py index 0d591d800..b9bf20f20 100644 --- a/backend/theme/serializers.py +++ b/backend/theme/serializers.py @@ -1,7 +1,7 @@ from os.path import join from django.conf import settings -from django.utils.translation import activate, gettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django_markup.markup import formatter @@ -47,8 +47,8 @@ def serialize_theme(theme: ThemeConfig) -> dict: 'description': theme.description, 'headingFontUrl': theme.heading_font_url, 'bodyFontUrl': theme.body_font_url, - 'logoUrl': join(settings.MEDIA_URL, str(theme.logo_image.file)) if theme.logo_image else None, - 'backgroundUrl': join(settings.MEDIA_URL, str(theme.background_image.file)) if theme.background_image else None, + 'logoUrl': f'{settings.BASE_URL.strip("/")}/{settings.MEDIA_URL.strip("/")}/{str(theme.logo_image.file)}' if theme.logo_image else None, + 'backgroundUrl': f'{settings.BASE_URL.strip("/")}/{settings.MEDIA_URL.strip("/")}/{str(theme.background_image.file)}' if theme.background_image else None, 'footer': serialize_footer(theme.footer) if hasattr(theme, 'footer') else None, 'header': serialize_header(theme.header) if hasattr(theme, 'header') else None }