PhoenixKit 2.30.0: Emails from database templates work again
PhoenixKit 2.30.0 fixes emails sent from templates stored in the database, which failed on every send. It also lets a host app protect its own files from orphan cleanup and gives modules a preview card and a featured image action.
Database email templates
On a site with the stock email templates in the database, every such email raised an error: registration confirmation, password reset, email change, and anything sent through Mailer.send_from_template. On a shop it showed as a guest checkout sending the buyer to an empty cart, because the confirmation email failed after the order was saved. These emails are sent again.
Orphan cleanup knows the host’s files
Orphan detection only knew about the file references core ships with, so files referenced only by a host app’s own tables could be deleted by a cleanup run. A host can now list its references in config :phoenix_kit, :file_reference_sources, with short forms for a table column or a JSON key. Every orphan count, list and the check before an orphan is deleted take them into account. Add them before running orphan cleanup on a site whose own tables point at media files.
For modules
- A preview card component shows a resource in a modal with one swipeable carousel of its images and files, a strip of thumbnails, its fields and a file list.
- The media browser can offer Set as featured and Unset featured on images, with a star on the current one. The host app stores the choice. A file in the trash cannot be made featured.
Upgrading
No migration. Hosts with their own tables that reference media files should register them in :file_reference_sources.
Full release notes: PhoenixKit 2.30.0
2.30.0 · 18 September 2026
Added
PhoenixKitWeb.Components.Core.PreviewCard(#827) — the catalogue’s product card, generalised into core.preview_card/1renders a modal whose media area is ONE continuous swipeable carousel (images first, then attached files; a PDF inline fromsmup, anything else as a tile with an Open action), a jump strip under it, the resource’s filled fields and a compact file list. Slide switching is entirely client-side scroll-snap — the only server event left is the close.preview_card_body/1is the same content without the modal shell, for embedding the preview inline. The component is pure render: every DB-backed value (images,files,fields,title) is resolved by the caller, so it needs no database. The catalogue delegates to it in a follow-up once this releases.config :phoenix_kit, :file_reference_sources(#828) — orphan detection knew only about the references core itself ships with, so a host whose own tables point at files was one cleanup run away from losing them. A host can now register{module, function}/{module, function, args}entries returningNOT EXISTSdynamics over the file binding, with{table, column}and{table, :jsonb_key, key}shorthands for the common shapes. Every registered source is honoured byfind_orphaned_files/1,count_orphaned_files/1andfile_orphaned?/1— including the re-checkDeleteOrphanedFileJobruns before it deletes anything. A source whose table is missing, or whose function raises, is skipped with a warning instead of failing the query.- Optional host-owned featured image in
MediaBrowser(#829) — an opt-infeaturedattr (nilby default, so every existing consumer is untouched) turns on a “Set as featured” / “Unset featured” action for image files in the grid, list and stack kebabs plus the modal viewer’s sidebar, with a star badge on the current pointer. The browser never persists the choice: it relays{MediaBrowser, id, {:set_featured, uuid | nil}}to the host and moves its own badge ahead of the host’s write, which the host can correct with a laterfeaturedassign.
Fixed
- Email templates stored in the database raised
KeyErroron every send (#830).Email.Content.resolve/5‘s two branches answered in different shapes: the database branch mappedhtmlfrom the provider’shtml_bodybut tooktextfrom a:textkey no provider has ever had — core’s ownDefaultProvideranswers%{subject:, html_body:, text_body:}, andphoenix_kit_emailsvalidates exactly those three on every render. On an install with the stock templates seeded that broke registration confirmation, password reset and email change, plus everythingMailer.send_from_template/…sends. It surfaced as a guest checkout bouncing the shopper to an empty cart: the confirmation email raised after the order had committed and took the checkout LiveView down with it. The branch is now tested, including a test pinning the fallback branch so a future change cannot quietly swap which shape wins. - A trashed image could still be made the featured one (#829, post-merge review). The three kebab entries hide the action while the trash listing is up, but the viewer sidebar had no such gate — and a trash tile clicks straight through to the viewer — so a host could persist a pointer to a file already queued for deletion. The sidebar button now reads the file’s own status, which also covers a file trashed in another session while the listing is stale.
Changed
preview_card_body/1no longer takes a required:target(#827, post-merge review). The body renders no event of its own — slide switching is client-side, and the Close button lives in the modal’s action row — so inline embedders were being made to pass a value that did nothing.- The
:file_reference_sourcesdocumentation now states that core ANDs each returned expression onto the orphan query verbatim (#828, post-merge review). The prose had promised aNOT EXISTSwrapper that the code never applied, contradicting its own example; a host that believed it and returned a positiveEXISTSwould have inverted the query and marked exactly its referenced files as the orphans. MediaBrowser‘s:featureddocs now state that a host funnelling every{MediaBrowser, _, _}message intohandle_parent_info/2loses the message to that function’s catch-all (#829, post-merge review) — silently, with the star still flipping in the UI, rather than failing in any way the host would notice.
PhoenixKit 2.30.0. Install or update: {:phoenix_kit, "~> 2.30"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.