Skip to content

Commit

Permalink
Fait fonctionner les images dans les ePUBs si zds-site est dans /medi…
Browse files Browse the repository at this point in the history
…a/...
  • Loading branch information
philippemilink authored and Situphen committed Jul 24, 2022
1 parent 3379e58 commit 143a8e6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion zds/tutorialv2/epub_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 143a8e6

Please sign in to comment.