Skip to content

feat: support drag/paste image uploads and add a localize-images helper - #70

Merged
pfeerick merged 2 commits into
mainfrom
feat/upload-images-support
Aug 4, 2026
Merged

feat: support drag/paste image uploads and add a localize-images helper#70
pfeerick merged 2 commits into
mainfrom
feat/upload-images-support

Conversation

@pfeerick

@pfeerick pfeerick commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Localize helper (tools/download_external_images.py, new): the issue templates already tell contributors "Local ASSETS/ screenshots can be added by a maintainer after review," but there was no tool for that step — it was fully manual. This downloads any external image URLs still sitting in scripts.json into ASSETS/<slug>/screenshot-N.<ext> (matching the existing naming convention) and rewrites scripts.json to point at the local copies. --dry-run previews without writing; a failed image leaves its entry untouched rather than partially migrating it; an entry's existing slug (from any already-local images) is reused so a renamed entry doesn't split across two directories.
  • Drag/paste upload support: GitHub issue-form textareas natively support dragging or pasting an image directly into a field — GitHub uploads it and inserts Markdown image syntax (![image](https://github.com/user-attachments/assets/<uuid>)) at the cursor. The "Image URLs" field's parser only ever recognized bare URL lines, so this was previously silently dropped. extract_image_urls() now finds URLs anywhere in the text, not just at the start of a line, and both templates' descriptions mention the drag/paste option explicitly.
  • Because GitHub's upload-attachment URLs have no file extension in the path at all (unlike a raw GitHub URL ending in .png), the localize helper's extension detection falls back to sniffing the response's Content-Type header when the URL alone isn't enough.

Test plan

  • extract_image_urls() against bare URLs, Markdown-wrapped upload URLs, and mixed text — all extracted correctly
  • issue_to_scripts.py --mode insert with a Markdown-wrapped image URL — accepted; with genuinely invalid image text — still correctly rejected
  • download_external_images.py end-to-end against a scratch copy of scripts.json, real network download of the one entry (EdgeTX Flight Log) that currently has external URLs — all 4 images downloaded, verified as real PNGs, scripts.json correctly rewritten to local paths
  • uv run tools/test_sync_issue_template_options.py — 10 tests pass (unrelated to this change, confirming nothing else regressed)
  • uv run tools/validate_scripts.py / sync_issue_template_options.py --check — clean
  • YAML validity of both templates

🤖 Generated with Claude Code

pfeerick and others added 2 commits August 4, 2026 11:40
The "Image URLs" issue-form field only ever expected bare URLs (one per
line), but GitHub issue-form textareas natively support dragging or
pasting an image directly in, which GitHub inserts as Markdown image
syntax (![image](https://github.com/user-attachments/assets/<uuid>)) —
previously silently dropped by the bare-URL-line parser. Both templates'
descriptions now mention this, and issue_to_scripts.py's extract_image_urls
recognizes URLs anywhere in the text, not just at the start of a line.

Add tools/download_external_images.py: downloads the external image URLs
still sitting in scripts.json (submitted via the issue form, per the
existing "a maintainer will add these to ASSETS/ after review" note) into
ASSETS/<slug>/, rewriting scripts.json to point at the local copies.
Extension is taken from the URL when possible, falling back to sniffing the
response's Content-Type — needed because GitHub's upload-attachment URLs
have no file extension in the path at all. --dry-run previews without
writing anything; a failed image leaves its entry untouched rather than
partially migrating it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The auto-generated PR body still told reviewers to manually add screenshots
to ASSETS/ and update scripts.json by hand — now points at the new helper
script added in this same PR instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@pfeerick
pfeerick merged commit 4285e7b into main Aug 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant