Micropub replace.photo appears to append (can’t replace/delete photos)

I am having some trouble getting the response I expect when I try to replace images on a post using a script I wrote.

I tried to replace existing photo attachments on a post via Micropub (spec says “replace all values of the property”) using this process:

  1. Upload two tiny PNGs via POST /micropub/media (got 202 + Location URLs on my custom domain).
  2. Create a draft post via Micropub (form-encoded): h=entry, content=…, photo=,
    post-status=draft → got 202 + Location for the draft.
  3. Update via Micropub (JSON): action=update, url=, replace: { photo: } → got 200.
  4. Fetch with q=source → saw both images in content as tags; there was no photo property in the response.
  5. Try delete: action=update, url=, delete: [‘photo’] → HTTP 500 with generic error page;
    q=source still shows both images.
  6. media?q=source shows my uploaded images with sizes:{large} and cdn:{large}, so uploads themselves look fine.

Expected (per W3C Micropub spec)

  • replace.photo should replace all existing photo values with the new one.

Actual

  • replace.photo appends; photos end up inline in content and both attachments remain.
  • delete: [‘photo’] returns 500; cannot remove attachments via Micropub.

Questions

  • Is this the intended behavior of Micro.blog’s Micropub implementation for photo?
  • Is there a supported way to replace or remove attached photos via Micropub (or another API)?
  • If replace is intentionally append-only for photos, can this be documented, or is a fix/workaround planned?

Thanks!

Micro.blog does not currently allow replacing a file with one that has the same name as an existing file.

Thanks @jsonbecker! I tested the filename theory and unfortunately it doesn’t help.

I created a post with one image, then tried replace.photo three times with completely different URLs (different Unsplash images).

Each replace just kept appending:

  • Start: 1 photo
  • After first replace (different URL): 2 photos
  • After second replace (same URL): 3 photos
  • After third replace (different URL): 4 photos

So it seems like replace.photo just behaves like add.photo regardless of the filename. Even using the exact same URL twice creates a duplicate.

The W3C Micropub spec says replace should remove old values, but that’s not happening here.

You’re right, this is a limitation right now with our Micropub support. I’ll fix this. I think based on how other parts of Micro.blog work, it should replace the photos used in the post, but not actually delete the photo references in Uploads.

As a work-around, if you’re editing a post you could remove the current <img> tags from the text of the post before adding new photos. That would be the same thing as replace, because Micro.blog photo posts are essentially just HTML posts with <img> tags.

Thanks @manton !