Skip to content

Comments 0.4.8: Put comment attachments in a folder you choose

Comments 0.4.8 lets a Phoenix app decide which media folder a comment’s attachments go into, instead of always the media root.

The host names a function in config, and the module asks it once per comment:

config :phoenix_kit_comments, :attachments_parent_folder, {MyApp.Media, :parent_for}

The function gets the kind :comment_attachment, the uploader and the record the comment is on, and answers {:ok, folder_uuid}. Any other answer, or no config at all, keeps the files at the root. A file storage already held elsewhere is linked into the folder, not moved.

The hook cannot break an upload: a folder that no longer exists, an answer that is not a uuid, or a hook that raises or exits is logged, and the files stay at the root.

Full release notes: Comments 0.4.8

0.4.8 · 15 September 2026

Added

  • Comment attachments can be placed under a host-configured folder (config :phoenix_kit_comments, :attachments_parent_folder, {mod, fun}), instead of always landing at the media root; unset or a nil answer keeps the default. Placement uses core’s Storage.attach_file_to_folder/2, so a deduplicated file homed elsewhere is linked, never moved. Documented in the README and AGENTS.md.

Fixed

  • The attachment folder hook can no longer crash the comment component mid-upload: a folder uuid that no longer exists (an FK violation core raises rather than returns), a non-uuid answer, and a hook that exits (e.g. a GenServer.call to a dead process) are all logged and leave the files at the root.
  • The hook is asked once per comment instead of once per attached file.

Comments 0.4.8. Install or update: {:phoenix_kit_comments, "~> 0.4"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.