mirror of
https://github.com/projectsend/projectsend.git
synced 2026-10-05 21:01:33 +00:00
1b3f014f5f
The sign-in, password reset, setup and share-link pages drew a custom logo 48 pixels tall, so a square logo was a 48x48 stamp. It now gets a box 80 pixels tall and up to 240 wide, so a square logo reads and a wide one still fits a phone. ProjectSend's own logo is unchanged. The site name appeared nowhere on those pages except as the image's alt text. A new switch on Branding → Logo prints it under the logo. It is off by default, because many logos already say the name and would then say it twice. It is stored on the branding row, gated like the rest of the screen (staff, edit_settings, branding.customize), and a withheld capability takes it off the pages along with the logo. The branding API's logo endpoint reports it as show_site_name. The Logo tab now says what size to use and which formats are accepted. SVG stays refused: it can carry script, and the logo is served from the site's own origin. The crop tool the issue also asks for is not part of this. Reported by @jiits (#1798)
93 lines
2.9 KiB
PHP
93 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Platform\Branding\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use App\Modules\Platform\Branding\Watermark\WatermarkPosition;
|
|
|
|
/**
|
|
* A single-row settings table — see the migration's comment for why no
|
|
* tenant/owner column is needed.
|
|
*
|
|
* @property int $id
|
|
* @property string|null $logo_path
|
|
* @property bool $watermark_enabled
|
|
* @property string|null $watermark_path
|
|
* @property WatermarkPosition $watermark_position
|
|
* @property int $watermark_size
|
|
* @property int $watermark_opacity
|
|
* @property bool $hide_attribution
|
|
* @property bool $show_site_name
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
*/
|
|
class BrandingSetting extends Model
|
|
{
|
|
protected $table = 'branding_settings';
|
|
|
|
protected $guarded = [];
|
|
|
|
protected $casts = [
|
|
'watermark_enabled' => 'boolean',
|
|
'show_site_name' => 'boolean',
|
|
'watermark_position' => WatermarkPosition::class,
|
|
'watermark_size' => 'integer',
|
|
'watermark_opacity' => 'integer',
|
|
'hide_attribution' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* Mirrors the migration's column defaults, so an unsaved instance
|
|
* answers the same as a freshly created row would. That is what lets
|
|
* the settings screen render `new BrandingSetting` on an install that
|
|
* has never touched branding, instead of either creating a row on a
|
|
* GET or restating these numbers a second time in the controller.
|
|
*/
|
|
protected $attributes = [
|
|
'watermark_enabled' => false,
|
|
'show_site_name' => false,
|
|
'watermark_position' => 'bottom-right',
|
|
'watermark_size' => 30,
|
|
'watermark_opacity' => 60,
|
|
'hide_attribution' => false,
|
|
];
|
|
|
|
public static function current(): self
|
|
{
|
|
return static::query()->firstOrCreate([]);
|
|
}
|
|
|
|
public function logoUrl(): ?string
|
|
{
|
|
return $this->logo_path === null ? null : Storage::disk('public')->url($this->logo_path);
|
|
}
|
|
|
|
public function watermarkUrl(): ?string
|
|
{
|
|
return $this->watermark_path === null ? null : Storage::disk('public')->url($this->watermark_path);
|
|
}
|
|
|
|
/**
|
|
* The artwork to stamp on a thumbnail being rendered right now, or
|
|
* null when this installation is not watermarking.
|
|
*
|
|
* Phrased as "which image, if any" rather than as a boolean because
|
|
* the toggle alone is not enough to act on: removing the image
|
|
* leaves the toggle standing, and a row restored from a backup can
|
|
* carry an `enabled` that its file no longer backs. Answering both
|
|
* halves at once means a caller cannot check one and use the other.
|
|
*/
|
|
public function activeWatermarkPath(): ?string
|
|
{
|
|
return $this->watermark_enabled ? $this->watermark_path : null;
|
|
}
|
|
|
|
public function watermarksThumbnails(): bool
|
|
{
|
|
return $this->activeWatermarkPath() !== null;
|
|
}
|
|
}
|