Minor nits, consider `"src" not in img` or `img["src"].startswith("data:")`