PhoenixKit 2.23.2: Choose the media folder for avatars and logos
PhoenixKit 2.23.2 lets a site decide which media folder its own uploads go to: user avatars, and the logo, site icon and sign-in background set in the admin settings. Until now they always landed in the storage root.
The app sets config :phoenix_kit, :uploads_parent_folder, {MyApp.Media, :parent_for}. The function gets the kind of upload (:avatar or :branding) and the uploading user, and returns {:ok, folder_uuid}, or nil for the root. An answer that is not a live folder, or a function that crashes, falls back to the root. Note that the avatar and branding pickers then show only files inside that folder.
The standalone media selector also accepts ?scope_folder=<uuid> and puts its uploads in that folder. Files attached to annotation comments can be placed the same way, through config :phoenix_kit_comments, :attachments_parent_folder.
Upgrading
Nothing to do unless you want the new placement: without the setting, uploads go to the root as before.
Full release notes: PhoenixKit 2.23.2
2.23.2 · 15 September 2026
Added
- Hosts can choose the folder core’s own uploads land in (#813).
config :phoenix_kit, :uploads_parent_folder, {Mod, :fun}is called asfun(kind, actor_uuid, subject)(orfun(kind, actor_uuid)) withkind:avataror:brandingand returns{:ok, folder_uuid}ornilfor the storage root (the default).Auth.update_user_avatar/4places the stored avatar there; the user form’s avatar picker and the logo / site-icon / auth-background pickers on/admin/settingsand/admin/settings/authorizationpass the answer toMediaSelectorModalasscope_folder_id. Note thatscope_folder_idalso scopes browsing, so once the hook is configured those pickers list only files under the returned folder. An answer that is not a live folder (not a UUID, no such folder, or trashed), or a hook that raises or exits, falls back to the root. - The standalone media selector accepts
?scope_folder=<uuid>(#813) and attaches uploads made from it to that folder; a malformed, missing or trashed folder is ignored.MediaSelectorHelper.media_selector_url/2takes a matching:scope_folderoption. - Annotation-comment attachments can be placed by the host (#813) through
config :phoenix_kit_comments, :attachments_parent_folder, called with:annotation_attachmentand%{resource_type: "file", resource_uuid: uuid}. - Storage moduledoc: folder conventions for module packages (#813) — the parent-folder and folder-name hooks, the lookup order for an object’s folder, and leaving re-parenting to the host.
Fixed
- The upload placement hook is consulted when a picker opens, not in
mount/3, so viewing a settings page or the user form no longer runs a host hook (which may create a folder) twice per load. - A hook answering a folder that no longer exists no longer crashes
Auth.update_user_avatar/4after the file was stored, nor the picker’s upload. - The standalone media selector logs a failed scope-folder attach instead of discarding it.
PhoenixKit 2.23.2. Install or update: {:phoenix_kit, "~> 2.23"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.