Skip to content

Commit

Permalink
fix: incorrect gif HTML
Browse files Browse the repository at this point in the history
Fixes rendering HTML for gifs referenced in Markdown and adds better animated image detection
  • Loading branch information
johnfraney committed Apr 27, 2024
1 parent a5f76ca commit 488cf83
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion blurry/markdown/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,22 @@ def image(self, text, url, title=None) -> str:
attributes["src"] = src

if extension.lower() in SETTINGS.get("VIDEO_EXTENSIONS"):
return render_video(src, absolute_path, extension, title=text)
return render_video(src, absolute_path, extension, title=title)

# Tailor srcset and sizes to image width
with Image(filename=str(absolute_path)) as img:
image_width = img.width
image_height = img.height
image_is_animated = img.animation
attributes["width"] = image_width
attributes["height"] = image_height

if image_is_animated:
attributes_str = " ".join(
f'{name}="{value}"' for name, value in attributes.items()
)
return f"<img {attributes_str} >"

image_widths = get_widths_for_image_width(image_width)

attributes["sizes"] = generate_sizes_string(image_widths)
Expand Down

0 comments on commit 488cf83

Please sign in to comment.