Keep attachment links with their entry, and expand them in HTML export !439

merged merged by cmc on 2026-11-22 01:51 UTC · krz/orgstar:attach-link-on-heading into main

Discussion

cmc

Two problems found scanning a document and taking a photo on a phone.

  • With the caret on a heading's line, the file was attached to that heading but ImageYank.inserting put the link on a new line above it, in the previous entry (or before the first heading). Following the link then reported "No file …", because that entry's attachment folder doesn't hold the file. The link now goes under the heading, after its planning line, drawers and clock lines (OrgAttach.belowHeading). This affects Take Photo…, Scan Document…, pasted images and dropped files.
  • HTMLExport.page wrote attachment: links unchanged (<img src="attachment:photo.jpg">). ExportPreprocess.attachments now turns them into file: links into the entry's attachment folder before parsing, as org-attach-expand-links does, falling back to the Org file's folder as Emacs 31 does. PDF export and Export to HTML and Open use the same page.
  • OrgSettings carries org-attach-id-dir and org-attach-use-inheritance for the exporter.

Markdown, LaTeX, ODT and ASCII export are unchanged.