From 57b71b6061802b2806529dbadc2358314c68f1a5 Mon Sep 17 00:00:00 2001 From: Emmanuel Jemeni Date: Wed, 22 Feb 2023 21:27:01 +0100 Subject: [PATCH] feat(ebook/__init__.py): leech checks if an image has an alt attribute and adds one if it doesn't --- ebook/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ebook/__init__.py b/ebook/__init__.py index 0cb0dc6..cf7ba9f 100644 --- a/ebook/__init__.py +++ b/ebook/__init__.py @@ -97,6 +97,8 @@ def chapter_html(story, titleprefix=None, normalize=False): content_type='image/png' )) img['src'] = f"../images/ch{i}_leechimage_{count}.png" + if not img.has_attr('alt'): + img['alt'] = f"Image {count} from chapter {i}" # Add all pictures on this chapter as well. for image in chapter.images: # For/else syntax, check if the image path already exists, if it doesn't add the image.