feat: support saving original image#548
Open
eszlamczyk wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the iOS ENRMImageAttachment behavior so UIKit “image actions” (Save to Photos / Copy Image / drag-and-drop) use the original downloaded image rather than the processed (scaled/clipped) render, while keeping on-screen rendering unchanged.
Changes:
- Separates “original image for system actions” (
NSTextAttachment.image) from “processed image for display” (loadedImageviaimageForBounds:). - Introduces a dedicated
placeholderImagesoimagecan remainniluntil the real image is available.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The image downloader invokes its completion synchronously on original-cache hits, which can happen on the async render queue during markdown parsing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
eszlamczyk
marked this pull request as ready for review
July 17, 2026 13:57
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.
What/Why?
Closes #380
Long-pressing an image in
EnrichedMarkdownTextand tapping Save to Photos saved the processed render instead of the source image. Instrumentation ofENRMImageAttachmentshowed that UIKit's attachment context menu, save action, and drag session all read the plainNSTextAttachment.imageproperty (_attachmentHasImage:,_imageFromAttachment:,_defaultMenuForInteractableItem), which we populated with:The fix separates the two roles the
imageproperty was playing:imagenow always holds the original downloaded image - set as soon as the download completes, on both the fresh-process and cache-hit paths. This is what UIKit serves to Save to Photos, Copy Image, drag-and-drop, and RTFD copy/paste.loadedImage, returned fromimageForBounds:for display - so on-screen rendering is unchanged.placeholderImageproperty. Before an image finishes loading,imageis nil, so the system no longer offers image actions that would save a blank pixel.Testing
In the example app (iOS simulator), with logging on the attachment accessors:
800×207instead of the clipped341×200render).80×73instead of the processed20×20thumbnail.imageForBounds:still returns the processed bitmap for drawing (sizing and border radius intact), and the drag preview still shows the rendered view.Screenshots
Note the cut corners
PR Checklist