From 143a8e6036bbe1245407a148406c5b0104dfd7cf Mon Sep 17 00:00:00 2001 From: Philippe MILINK Date: Sun, 17 Jul 2022 23:32:09 +0200 Subject: [PATCH] Fait fonctionner les images dans les ePUBs si zds-site est dans /media/... --- zds/tutorialv2/epub_utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/zds/tutorialv2/epub_utils.py b/zds/tutorialv2/epub_utils.py index 538ea872c2..3f5e7be710 100644 --- a/zds/tutorialv2/epub_utils.py +++ b/zds/tutorialv2/epub_utils.py @@ -206,7 +206,14 @@ def handle_image_path_with_good_img_dir_path(html_code): if self.url_scheme_matcher.search(image_url): splitted = parse.urlsplit(image_url) final_path = splitted.path - elif image_url.startswith(settings.MEDIA_URL): + elif (not (Path(settings.MEDIA_URL).is_dir() and Path(image_url).exists())) and image_url.startswith( + settings.MEDIA_URL + ): + # do not go there if image_url is the path on the system + # and not a portion of web URL + # (image_url.startswith(settings.MEDIA_URL) can be True if + # zds-site is in a directory under /media (the default + # value of settings.MEDIA_URL)) final_path = Path(image_url).name elif Path(image_url).is_absolute() and "images" in image_url: root = Path(image_url)