feat: support drag/paste image uploads and add a localize-images helper - #70
Merged
Conversation
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 () — 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tools/download_external_images.py, new): the issue templates already tell contributors "LocalASSETS/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 inscripts.jsonintoASSETS/<slug>/screenshot-N.<ext>(matching the existing naming convention) and rewritesscripts.jsonto point at the local copies.--dry-runpreviews 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.) 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..png), the localize helper's extension detection falls back to sniffing the response'sContent-Typeheader when the URL alone isn't enough.Test plan
extract_image_urls()against bare URLs, Markdown-wrapped upload URLs, and mixed text — all extracted correctlyissue_to_scripts.py --mode insertwith a Markdown-wrapped image URL — accepted; with genuinely invalid image text — still correctly rejecteddownload_external_images.pyend-to-end against a scratch copy ofscripts.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.jsoncorrectly rewritten to local pathsuv 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🤖 Generated with Claude Code