Idea: MIME-inspired mapping between content and attachment for inline media handling
#2430
Jiwoon-Kim
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
📨 Idea: MIME-inspired mapping between
contentandattachmentfor inline media handlingContext
Using a plugin like [Regenerate Thumbnails](https://wordpress.org/plugins/regenerate-thumbnails/) can pose a significant risk when dealing with a large number of image files — especially in federated environments such as the Fediverse.
Since ActivityPub synchronizes both metadata and media references, bulk file replacements can easily lead to mismatched attachments, broken remote objects, and unnecessary federation updates.
To reduce these risks, I’d like to propose an architectural enhancement inspired by email MIME structure, particularly how it manages inline images and attachments.
Background: MIME analogy
In email systems, a message is built as a
multipart/relatedstructure, consisting of:Content-Type: text/html)cid:URIs)multipart/mixed)Example structure:
This structure semantically links each inline
<img>tag in the body with its corresponding media resource viaContent-ID.The client (e.g., Outlook, Gmail, Naver Mail) resolves those identifiers to display images locally or remotely, maintaining data integrity across transfers.
Proposal: MIME-like mapping for ActivityPub
In ActivityPub, the
Articleobject’scontentfield serves a similar role to the MIME body, and theattachmentarray can represent its related media parts.However, current implementations do not explicitly map embedded media references (e.g.,
<img>tags insidecontent) to their correspondingattachmententries.I propose a semantic mapping mechanism inspired by MIME’s
Content-IDrelationship:{ "type": "Article", "content": "<p>Hello World <img src=\"cid:image001\" alt=\"sample\"></p>", "attachment": [ { "type": "Image", "id": "https://example.com/media/123", "name": "sample.png", "contentId": "image001", "mediaType": "image/png", "url": "https://example.com/media/123.png" } ] }In this model:
<img src="cid:image001">withincontentrefers to the matchingattachmentwith"contentId": "image001".mediaLibendpoint (or future FMO extensions), minimizing redundant synchronization.Benefits
contentandattachmentfor richer federation.Conclusion
By borrowing the semantic structure of MIME (body + related parts), the ActivityPub plugin can manage inline media more predictively and safely — especially in federated WordPress environments where automatic media regeneration poses synchronization risks.
This approach could form the basis for an optional mapping layer between
contentandattachment, paving the way for improved media interoperability in future versions.Optional Future Discussion Points
cid:URI syntax be standardized or replaced with a more ActivityPub-native identifier (e.g.,apid:ormlid:)?mediaLibor FMO-based endpoints?🧠 Implementation Sketch:
contentIdmapping layer for inline mediaConcept Overview
Building on the MIME-inspired structure proposed above, this section outlines how the
contentIdmapping could be implemented within the WordPress ActivityPub plugin — while remaining backward-compatible with current JSON-LD representations.The goal is to link
<img>elements incontentwith their correspondingattachmententries in a predictable, verifiable way.1. Extended Attachment Object Schema
In
class-transformer/attachment.php, we could extend the serialization schema to include an optionalcontentIdfield.This field wouldn’t affect existing ActivityPub consumers — it simply enriches the data for systems that support inline mapping.
2. HTML Content Preprocessing
When transforming a post to an ActivityPub
Articleobject, the content could be parsed and updated withcid:references, similar to how email systems link embedded media.Resulting
content:This creates a logical bond between the inline image and its metadata without altering how browsers or ActivityPub clients render the content.
3. Optional Fallback and Compatibility
To maintain compatibility:
cid:can still display images normally by resolvingurlas usual.contentIdto verify media integrity before fetching.mediaLibor FMO extension is available, the plugin could pre-register predictable file hashes or sizes to support decentralized caching.4. Future Extension: Media Integrity and Prediction
Once the mapping exists, each instance could optionally publish predictive metadata:
This allows remote instances to decide whether to reuse, re-render, or skip download of a file — similar to how MIME email clients validate cached inline images.
5. Summary of Key Benefits
mediaLib/ FMO endpoint conceptsConclusion
By introducing a lightweight
contentIdmapping layer, WordPress ActivityPub could bridge the semantic gap betweencontentandattachment— in the same way MIME solved body-resource linkage decades ago.This would make the plugin not only more resilient against media regeneration issues (like with Regenerate Thumbnails),
but also more interoperable with future ActivityPub extensions related to media verification, predictive caching, or decentralized asset distribution.
Beta Was this translation helpful? Give feedback.
All reactions