class EmailLogo

The logo shown at the top of HTML emails.

The forum logo is stored as WebP, which many mail clients (Outlook on Windows among them) can't display. Emails therefore use a PNG (or, for an animated logo, GIF) image instead: an email logo the admin uploaded, or a copy made automatically whenever the forum logo is uploaded. Each image's pixel size is stored alongside its path, so the email can carry explicit width and height attributes — Outlook ignores CSS sizing — without reading the file from the assets disk every time a message is sent.

Constants

DISPLAY_HEIGHT

The height, in CSS pixels, the logo is shown at in emails.

MAX_DISPLAY_WIDTH

The widest the logo is shown, in CSS pixels: the 600px email body less its padding.

SCALE

Images are stored at twice their display size so they stay sharp on HiDPI screens.

PATH_KEY

SIZE_KEY

COPY_PATH_KEY

COPY_SIZE_KEY

Properties

protected Cloud $assetsDir

Methods

__construct( SettingsRepositoryInterface $settings, ImageManager $imageManager, Factory $filesystemFactory)

No description

array
encode( ImageInterface $image)

Scale an image down to the stored email size and encode it in a format mail clients can display. Never enlarges the image.

void
storeCopy(string $sourcePath)

Store an email-safe copy of a newly uploaded forum logo, replacing any previous copy.

void
deleteCopy()

No description

void
deleteCopyFile()

No description

array|null
resolve()

The logo to show in emails, if there is one a mail client can display.

array
displaySize(string|null $storedSize)

The size, in CSS pixels, to show an image of the given stored size at.

Details

__construct( SettingsRepositoryInterface $settings, ImageManager $imageManager, Factory $filesystemFactory)

Parameters

SettingsRepositoryInterface $settings
ImageManager $imageManager
Factory $filesystemFactory

array encode( ImageInterface $image)

Scale an image down to the stored email size and encode it in a format mail clients can display. Never enlarges the image.

Parameters

ImageInterface $image

Return Value

array The encoded image, its file extension, and its size as "WIDTHxHEIGHT".

void storeCopy(string $sourcePath)

Store an email-safe copy of a newly uploaded forum logo, replacing any previous copy.

Parameters

string $sourcePath

Return Value

void

void deleteCopy()

Return Value

void

protected void deleteCopyFile()

Return Value

void

array|null resolve()

The logo to show in emails, if there is one a mail client can display.

In order: the uploaded email logo; the copy of the forum logo; the forum logo itself, but only if it isn't WebP (logos uploaded before they were converted to WebP are PNG, JPEG or GIF). The width and height are null when the image's size isn't known.

Return Value

array|null

protected array displaySize(string|null $storedSize)

The size, in CSS pixels, to show an image of the given stored size at.

Parameters

string|null $storedSize

Return Value

array