feat:Adding image upload handler functionality to PPTX converter #1197
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.
Key Changes
Image Upload Handler
Introduced support for a user-defined
upload_handler
function that uploads extracted images to storage.The handler receives binary image data along with metadata and returns the uploaded image URL.
Unique Filename Generation
Each image is assigned a unique filename using UUID.
The original file extension is preserved.
Error Handling and Fallback Logic
If the upload handler fails, the converter falls back to the existing behavior.
If the returned URL is invalid, a fallback mechanism is applied.
Test Cases
How It Works
Image Extraction & Preparation
When an image is detected in a PowerPoint slide:
123e4567-e89b-12d3-a456-426614174000.jpg
)Upload Handler Call
The extracted image data and metadata (
filename
,content_type
) are passed to the user-definedupload_handler
.Markdown Generation
The handler's returned URL is inserted into the Markdown as an image link:

If the handler fails, the fallback uses a data URI or just the filename, based on settings.
Error Handling
All exceptions during upload are handled gracefully.
If the URL returned by the handler is invalid, fallback logic is applied.
Example Usage
Test Coverage
This PR includes tests to verify:
That the URL returned by the handler is correctly inserted into the Markdown
That metadata contains all required fields
That image binary data is passed properly
That the handler works under concurrent conversions
That fallback behavior works on handler exceptions
That invalid return values from the handler are handled properly
This feature enables integration with external storage systems when converting images from PowerPoint presentations to Markdown, improving image management and enhancing the reusability of the resulting Markdown documents.