(article_path: Path, ref: ImageRef, *, staged: bool, args: argparse.Namespace, root: Path)
| 343 | |
| 344 | |
| 345 | def image_issue(article_path: Path, ref: ImageRef, *, staged: bool, args: argparse.Namespace, root: Path) -> str | None: |
| 346 | target = ref.target.strip() |
| 347 | if not target: |
| 348 | return "image target is empty" |
| 349 | |
| 350 | lower_target = target.lower() |
| 351 | if lower_target.startswith("data:image/"): |
| 352 | return None |
| 353 | if lower_target.startswith("data:"): |
| 354 | return "data URI is not an image" |
| 355 | if target.startswith("//"): |
| 356 | if not args.check_remote_images: |
| 357 | return None |
| 358 | return remote_image_issue(f"https:{target}", args.remote_image_timeout) |
| 359 | |
| 360 | split = urlsplit(target) |
| 361 | if split.scheme in {"http", "https"}: |
| 362 | if not args.check_remote_images: |
| 363 | return None |
| 364 | return remote_image_issue(target, args.remote_image_timeout) |
| 365 | |
| 366 | return local_image_issue(article_path, target, staged=staged, root=root) |
| 367 | |
| 368 | |
| 369 | def check_images( |
no test coverage detected