Skip to content

[2.x] fix: resolve email logo URL via flarum-assets disk#4640

Merged
imorland merged 1 commit into2.xfrom
im/email-logo-disk-url
May 7, 2026
Merged

[2.x] fix: resolve email logo URL via flarum-assets disk#4640
imorland merged 1 commit into2.xfrom
im/email-logo-disk-url

Conversation

@imorland
Copy link
Copy Markdown
Member

@imorland imorland commented May 7, 2026

Summary

The HTML email layout built the logo <img src> as:

$url->to('forum')->base() . '/assets/' . $settings->get('logo_path')

On installs serving assets from a remote bucket or CDN, the actual logo file lives at the flarum-assets disk's resolved URL — not under forum-base/assets/. Every email those installs rendered showed a broken logo.

Resolve the logo URL via the same flarum-assets disk that ForumResource::getLogoUrl() uses for the frontend, and share it to email views as a precomputed $logoUrl.

Fixes #4604

Changes

Compatibility

  • Local-disk installs (default): the flarum-assets disk's url() returns https://forum.example.com/assets/<path> — same URL the old concatenation produced. No observable change.
  • S3 / CDN installs: the disk now returns the actual asset URL. Logos render where the file is.
  • Third-party extensions that already pass their own $logoUrl to an email render via ->with('logoUrl', ...) still win — Laravel's local with() overrides global share().

Test plan

  • Existing mailer-related integration tests pass (7/7).
  • Manual: send a test email on a local-disk install — logo renders unchanged.
  • Manual on S3-backed install: send a test email — logo loads from the bucket/CDN URL.

Notes

  • No automated test for the rendered HTML body — would need to capture mailer output and inspect the <img src> attribute, which is heavyweight relative to the size of this change. The fix mirrors a pattern already exercised everywhere else in core that resolves asset URLs.
  • The plain-text email template doesn't include the logo, so no change there.
  • Dark-mode logo handling in emails is out of scope — most mail clients can't reliably swap images per dark mode anyway.

The HTML email layout built the logo src as
$url->to('forum')->base() . '/assets/' . $logo_path. On installs
serving assets from a remote bucket or CDN, the actual file is at
the disk's URL, not under the forum base — every email rendered a
broken logo image.

Resolve the logo URL via the flarum-assets disk in MailServiceProvider
and share it as a precomputed $logoUrl view variable. Same resolver
ForumResource::getLogoUrl() already uses for the frontend, so local
installs (where the disk URL coincides with /assets/...) are unchanged.

Fixes #4604
@imorland imorland requested a review from a team as a code owner May 7, 2026 00:44
@imorland imorland added this to the 2.0.0-rc.2 milestone May 7, 2026
@imorland imorland merged commit 918db9c into 2.x May 7, 2026
25 checks passed
@imorland imorland deleted the im/email-logo-disk-url branch May 7, 2026 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.x] Logo in mail template resolves to flarum local disk by default

1 participant