From 3d4ec8382dc89e94a448205b17a77fb138be59bf Mon Sep 17 00:00:00 2001 From: Serge Noiraud Date: Tue, 29 Dec 2020 10:01:25 +0100 Subject: [PATCH] Narweb: in cms mode, some inconsistent image links (#1157) --- gramps/plugins/webreport/basepage.py | 5 +++-- gramps/plugins/webreport/media.py | 6 ++++-- gramps/plugins/webreport/narrativeweb.py | 14 ++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/gramps/plugins/webreport/basepage.py b/gramps/plugins/webreport/basepage.py index 92687ba06..99ea45e26 100644 --- a/gramps/plugins/webreport/basepage.py +++ b/gramps/plugins/webreport/basepage.py @@ -2054,7 +2054,7 @@ class BasePage: image=True) imag.attr += ' src = "%s" alt = "%s"' % (newpath, descr) fname = self.report.build_url_fname(obj.get_handle(), - "img", False, + "img", uplink=2, image=True, ) + self.ext inc_gallery = self.report.options['gallery'] @@ -2771,7 +2771,8 @@ class BasePage: of the result. @param: usedescr -- Add media description """ - url = self.report.build_url_fname_html(media_handle, "img", uplink) + url = self.report.build_url_fname(media_handle, "img", uplink, + image=True) + self.ext name = html_escape(name) # begin thumbnail division diff --git a/gramps/plugins/webreport/media.py b/gramps/plugins/webreport/media.py index db091a093..b7125d608 100644 --- a/gramps/plugins/webreport/media.py +++ b/gramps/plugins/webreport/media.py @@ -335,7 +335,8 @@ class MediaPages(BasePage): result. """ # get media url - url = self.report.build_url_fname_html(handle, "img", uplink) + url = self.report.build_url_fname(handle, "img", uplink=2, + image=True) + self.ext # get name name = html_escape(name) @@ -642,7 +643,8 @@ class MediaPages(BasePage): @param: uplink -- If True, then "../../../" is inserted in front of the result. """ - url = self.report.build_url_fname_html(handle, "img", uplink) + url = self.report.build_url_fname(handle, "img", uplink, + image=True) + self.ext name = html_escape(name) return Html("a", name, name=name, id=name, href=url, title=name, inline=True) diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py index 402ce8d62..85e786bac 100644 --- a/gramps/plugins/webreport/narrativeweb.py +++ b/gramps/plugins/webreport/narrativeweb.py @@ -1408,10 +1408,16 @@ class NavWebReport(Report): else: subdirs = [self.target_uri] + subdirs elif self.target_uri not in fname: - subdirs = [self.target_uri] + [fname] + if self.the_lang and subdir not in ["css", "images", "thumb"]: + subdirs = [self.target_uri] + [self.the_lang] + [fname] + else: + subdirs = [self.target_uri] + [fname] else: subdirs = [] else: + if self.the_lang and image and uplink != 2: + if subdir and subdir[0:3] not in ["css", "ima", "thu"]: + subdirs = [self.the_lang] + subdirs if uplink is True: nb_dir += 3 subdirs = ['..']*nb_dir + subdirs @@ -1597,12 +1603,12 @@ class NavWebReport(Report): False, image) if self.target_uri in subdirs and image: subdirs.remove(self.target_uri) - if subdir[0:3] in ["css", "ima", "thu"]: + if subdir[0:3] in ["css", "img", "ima", "thu"]: subdirs = [self.target_uri] + subdirs else: - if fname[0:3] in ["css", "ima", "thu"]: + if fname[0:3] in ["css", "img", "ima", "thu"]: subdirs = [self.target_uri] - elif fname[3:6] in ["css", "ima", "thu"]: + elif fname[3:6] in ["css", "img", "ima", "thu"]: subdirs = [self.target_uri] fname = fname[3:] else: