Skip to content

Conversation

@alltheseas
Copy link
Collaborator

@alltheseas alltheseas commented Dec 27, 2025

Summary

Detect image URLs in the post composer and display them as image previews. When users type or paste image URLs (jpg, jpeg, png, gif, webp, svg), the URLs are automatically detected and converted to image previews in the media carousel. The URL is removed from the post text to avoid duplication (it gets re-added when posting via the existing build_post() logic).

Features:

  • Detect image URLs after whitespace/newline (when typing)
  • Detect image URLs immediately on paste
  • Show carousel position badge (e.g., "1/2") for multiple images
  • Exclude fragment URLs (#) which don't return actual images (e.g., Wikipedia media viewer URLs)

Checklist

Standard PR Checklist

  • I have read (or I am familiar with) the Contribution Guidelines
  • I have tested the changes in this PR
  • I have profiled the changes to ensure there are no performance regressions, or I do not need to profile the changes.
    • If not needed, provide reason: Changes are limited to post composer text processing with simple regex matching; no heavy computations or loops over large datasets
  • I have opened or referred to an existing github issue related to this change: Feature Request: Recognize Pasted Image URLs as Images #2288
  • My PR is either small, or I have split it into smaller logical commits that are easier to review
  • I have added the signoff line to all my commits. See Signing off your work
  • I have added appropriate changelog entries for the changes in this PR. See Adding changelog entries
  • I have added appropriate Closes: or Fixes: tags in the commit messages wherever applicable, or made sure those are not needed. See Submitting patches

Test report

Device: iPhone 17 Pro Simulator

iOS: 26

Damus: 2bcef51

Setup: Fresh install on simulator

Steps:

  1. Open post composer
  2. Type an image URL (e.g., https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Banana-Single.jpg/800px-Banana-Single.jpg) followed by a space
  3. Verify URL is removed from text and image preview appears
  4. Paste an image URL directly (without trailing space)
  5. Verify image preview appears immediately
  6. Add multiple images and verify "1/2", "2/2" badge updates when scrolling
  7. Verify fragment URLs (e.g., https://example.com/page#image.png) are not detected

Results:

  • PASS

Other notes

When typing or pasting image URLs (jpg, jpeg, png, gif, webp, svg) in the
post composer, the URLs are automatically detected and converted to image
previews. The URL is removed from the text to avoid duplication (it gets
re-added when posting).

Features:
- Detect image URLs after whitespace/newline (typing)
- Detect image URLs on paste (immediate preview)
- Show carousel position badge (e.g., "1/2") for multiple images
- Exclude fragment URLs (#) which don't return actual images

Closes: damus-io#2288

Changelog-Added: Added image URL detection and preview in post composer
Changelog-Added: Added position indicator badge to image carousel in post composer

Signed-off-by: alltheseas <[email protected]>
@alltheseas
Copy link
Collaborator Author

Screenshot 2025-12-27 at 1 54 13 PM

@alltheseas alltheseas changed the title Detect image URLs in post composer and display previews Detect image URLs in post composer and display previews + add carousel picture counter badge Dec 28, 2025
@danieldaquino danieldaquino added the pr-in-queue This PR is waiting in a queue behind their other PRs marked with the label `pr-active-review`. label Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

media pr-in-queue This PR is waiting in a queue behind their other PRs marked with the label `pr-active-review`. ui usability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants