Configuration
Config file
The Manager writes settings to the following file. If it is missing, sGallery uses the package defaults.
../core/custom/config/seiger/settings/sGallery.php
Simple configuration
The easiest way to add a gallery to a resource is to set up an array of numbers.
<?php return [1, 3, 5];
This array contains a list of resource template IDs. If you use this simple setting, an additional tab with a gallery will be added to the resources with the template listed.
More than one tab
Since 1.7.0, use the resource template ID as the key and a list of tab names as its value:
<?php return [
5 => ['slider', 'top-sales'],
1,
3,
];
Template 5 receives two named galleries. Templates 1 and 3 receive a standard gallery tab.
Keep named assignments before simple IDs: PHP automatically allocates integer keys to unkeyed entries, and a later explicit key could overwrite an earlier entry. The settings interface uses this order when saving. Simple configurations such as [1, 3, 5] remain supported and are still written as plain ID lists.
Deprecated nested assignments
The following format is deprecated since 1.7.0, but remains readable for backward compatibility:
<?php return [
1,
3,
[5 => ['slider', 'top-sales']],
];
The manager shows a deprecation notice when this format is present. Changing gallery settings and saving converts assignments to the flat format. Merely opening the page or saving unrelated system settings does not rewrite the gallery configuration. Older package versions still support the simple ID list, but require the nested format for named tabs.
Manager gallery permissions
Resource galleries require a manager session and access to the parent resource. Reading requires view_document or edit_document. Adding media, reordering and editing translations require both edit_document and save_document. Deleting also requires delete_document. For named blocks, assign the block to the resource template. The default block is 1.
Integrations with their own parent types can register an action and resource check in itemPolicies:
<?php return [
1,
'itemPolicies' => [
'product' => [\App\Gallery\ProductPolicy::class, 'allows'],
],
];
The callable receives (string $action, int $parentId, string $block, $evolution) and must return true for the authorized action. The action is read, upload, uploadDownload, register, addYoutube, reorder, translate or delete. Set a policy for custom types used by non-administrators. Without one, custom galleries are available to administrators. A configured resource policy can allow additional block names after the normal CMS checks pass.
Adding a file from the browser requires file_manager or the corresponding assets_images / assets_files permission. The browser directory must be inside the site and the file must be within rb_base_dir. When image_base_upload_dir is set, new registrations must be within that directory too. Removing a shared library entry leaves its original file in the library.
Uploads and links
The package checks uploads against the configured CMS extensions and a supported server MIME type. New files receive a unique name and a canonical extension. On POSIX systems, new upload directories and files start from modes 0755 and 0644, reduced by the process umask. Existing upload locations and shared library files are retained.
Gallery links accept HTTP(S) URLs and relative links. Use Blade's escaped echo syntax for the link attribute in your templates. Entries with older links outside the current policy display with an empty link.
Generated image cache
Use the imageCacheDir key to choose the project-relative public directory for generated image derivatives.
<?php return [
1,
'imageCacheDir' => 'assets/derived/',
];
The default is assets/cache/ for backward compatibility. After changing the directory, run php artisan vendor:publish --tag=sGallery. It creates .gitignore and index.html in the selected directory without changing existing generated images.
Manager settings
Since 1.7.0, the system configuration page includes an sGallery tab for image quality, sharpening, output format, optimization, cache management, watermark defaults and resource template assignments. Use the system Save action: gallery settings are written only when their values have changed. Saving requires manager settings permissions and a valid request token.
Evolution loads core/custom/config/seiger/settings/sGallery.php automatically.
When it is absent, sGallery uses config/sGallerySettings.php from the package.
The custom file replaces the package defaults without merging template assignments.
The interface writes short PHP arrays with four-space indentation.
Thumbnail dimensions, the thumbnail fit method and the frontend optimization time
budget are package values, not editable settings. Configure each image transformation
through Builder methods such as fit() and resize().
Watermarks
Watermarks are opt-in: existing image calls remain unwatermarked unless they call
watermark(). All three forms are supported:
$options = ['position' => 'bottom-right', 'width' => '20%', 'opacity' => 100, 'padding' => '3%'];
sGallery::file($product->cover)->fit('crop', 800, 800)->watermark($watermarkPath, $options);
sGallery::file($product->cover)->fit('crop', 800, 800)->watermark($options);
sGallery::file($product->cover)->fit('crop', 800, 800)->watermark();
Without an explicit path, Builder uses watermark.file from settings. An empty
default path leaves the image unwatermarked. Select the default file with the
manager image browser; the file must be a local image supported by the driver.
Options override configured defaults for the current call only.
Without Spatie, GD or Imagick can apply a still watermark to supported native
derivatives. Imagick applies it to each frame of a GIF or WebP animation.
width and padding accept integer pixels or percentages. Width is measured
against the processed image width after resize/crop; percentage horizontal and
vertical padding use the processed width and height respectively. Watermark aspect
ratio is preserved. Opacity ranges from 0 (transparent) to 100 (opaque).
Watermarks are applied to cached derivatives after image transformations. Originals remain unchanged, and repeated Builder calls reuse the derivative. The cache key includes source and watermark contents and processing parameters, so changing the watermark or its options selects a new cached file.
The cache-clear button removes indexed sGallery derivatives and protects recorded source files. Files created before derivative indexing and unrelated cache files are left intact.
Output formats
Builder supports jpg, jpeg, png, gif, webp, avif and original, subject
to encoder availability. The visual settings offer AVIF, WebP and the original
extension. format('original') preserves the source extension while still applying
transformations; it does not mean returning an unprocessed original.