refactor the image function from hell

This commit is contained in:
crunk 2024-11-15 14:23:29 +01:00
parent 8146cb4831
commit 48f1889ee9

View File

@ -141,21 +141,21 @@ def handle_image_files(name, full_path, args):
thumbnail_filename = thumbnail(full_path, name, args) thumbnail_filename = thumbnail(full_path, name, args)
if thumbnail_filename is None: if thumbnail_filename is None:
return return
if args.alttexts:
image_alttext = add_alttext(full_path) image_alttext = add_alttext(full_path)
if args.alttexts: image_description = add_description(full_path)
image_description = add_description(full_path)
if image_alttext is None: if not image_alttext and not image_description:
if image_description is None: return image_no_description.format(
return image_no_description.format( name=name, thumbnail_filename=thumbnail_filename
name=name, thumbnail_filename=thumbnail_filename )
) if not image_alttext:
return image_with_description.format( return image_with_description.format(
name=name, name=name,
thumbnail_filename=thumbnail_filename, thumbnail_filename=thumbnail_filename,
image_description=image_description, image_description=image_description,
) )
if image_description is None: if not image_description:
return image_with_alttext.format( return image_with_alttext.format(
name=name, name=name,
thumbnail_filename=thumbnail_filename, thumbnail_filename=thumbnail_filename,