Skip to content

Commit c444c02

Browse files
committed
Fix a/href in image()
1 parent cb01316 commit c444c02

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

plugins/dltj_plugin/dltj_plugin.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ def image(
7070
str: HTML fragment
7171
"""
7272
alt = alt or ""
73+
if abssrc:
74+
img_path = abssrc
75+
else:
76+
img_path = f"https://dltj.org/assets/images/{localsrc}"
7377
output: str = "<figure "
7478
if fig_class:
7579
output += f'class="{fig_class}" '
@@ -78,16 +82,21 @@ def image(
7882
if width:
7983
output += f'style="width:{width}px" '
8084
output += ">"
81-
if ahref or localhref:
82-
output = f'<a href="{ahref}{localhref}">'
85+
if ahref:
86+
output = f'<a href="{ahref}">'
87+
elif localhref:
88+
output = f'<a href="{localhref}">'
89+
output += "<picture>"
90+
if picclass:
91+
output += f'<source class="{picclass}" src="{img_path}"></source>'
8392
output += "<img "
8493
if width:
8594
output += f'width="{width}" '
86-
if abssrc:
87-
output += f'src="{abssrc}" '
88-
else:
89-
output += f'src="https://dltj.org/assets/images/{localsrc}" '
95+
if imgclass:
96+
output += f'class="{imgclass}" '
97+
output += f'src="{img_path}" '
9098
output += f'alt="{alt}">'
99+
output += "</picture>"
91100
if ahref or localhref:
92101
output += "</a>"
93102
if caption:

0 commit comments

Comments
 (0)