Skip to content

Bluesky.create: upload images in cited attachments for external embed thumbs - #1214

Merged
snarfed merged 2 commits into
snarfed:mainfrom
miklb:bluesky-cite-thumbs
Oct 7, 2026
Merged

snarfed merged 2 commits into
snarfed:mainfrom
miklb:bluesky-cite-thumbs

Conversation

@miklb

@miklb miklb commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #1195.

create now also uploads images in article/link/note attachments, so to_external_embed finds a blob to use as thumb. They’re kept out of images so they don’t turn the post into an images embed.

These uploads are best effort: if a cited image can’t be fetched, or it’s over the thumb lexicon maxSize, it logs a warning and posts the embed without a thumb, which is what happens today. That needed a max_size kwarg on upload_media. I modeled it on how Bridgy Fed fetches blobs in atproto.py.

Happy to change it if you’d rather these fail loudly, or want the check somewhere else.

Two things I left out. Let me know if you want either:

  • Checking the fetched image’s Content-Type against the thumb’s accept
    (image/*).
  • Skipping the upload for attachments that become quote posts (at:// and
    bsky.app URLs), where the image is never used.

Tests cover the thumb, a 404, and an oversized image.

I could follow what was happening with the failing on the end result (image not showing up) and was able to trace it back, but to be clear I only half read Python so I leaned on Claude for the rest.

… thumbs, for snarfed#1195

Signed-off-by: Michael Bishop <howdy@michaelbishop.me>

@snarfed snarfed left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @miklb, this is great! I'll make some tweaks and merge soon.

Comment thread granary/tests/test_bluesky.py Outdated
Comment thread granary/tests/test_bluesky.py Outdated
Comment thread granary/bluesky.py Outdated
Comment thread granary/bluesky.py Outdated
Comment thread README.md Outdated
@snarfed
snarfed enabled auto-merge (squash) October 7, 2026 03:26
Co-authored-by: Ryan Barrett <github@ryanb.org>
@snarfed
snarfed force-pushed the bluesky-cite-thumbs branch from 8c8dd50 to 03909dd Compare October 7, 2026 03:37
@snarfed
snarfed merged commit 179317a into snarfed:main Oct 7, 2026
3 checks passed
@snarfed

snarfed commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Done! I'm deploying this to Bridgy classic now...

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.

Bluesky: upload images from cited attachments so external embeds get thumbnails

2 participants