Skip to content

feat(docs): replace-image command (replaceImage) — swap image bytes in place without losing position/size #853

Description

@sebsnyk

The Docs API replaceImage request swaps the bytes behind an existing inline image while preserving its position, size, and surrounding paragraphs — only the pixels change. gog docs has no command for it. Today the only way to refresh a diagram is delete the positioned object + insert-image again, which loses the original placement and re-applies a default width, so every refresh needs manual re-positioning.

This is a common workflow: a doc embeds a generated diagram, the source regenerates, and you want to drop in new bytes without disturbing layout.

Proposed:

gog docs replace-image <docId> --file <local.png>          # upload, then ReplaceImageRequest
gog docs replace-image <docId> --url <https-url>
  --match-alt <substring>   # pick when the doc has multiple inline images (match on alt/description)
  --object-id <id>          # explicit positioned-object id (from `gog docs images list`)
  --tab <tab>

images list already enumerates the inline objects, so an --object-id selector falls out naturally; --match-alt is the ergonomic path. The upload half can reuse whatever insert-image --file already does for restricted-tenant embedding.

Ref: documents.batchUpdate ReplaceImageRequest (imageObjectId, uri, imageReplaceMethod).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:human-reviewClawSweeper automerge is paused for maintainer reviewclawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.no-staleExempts this issue from stale automation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions