Search by

clesson-de / silverstripe-elemental-essentials

clesson-de

Essential text, image, video and audio content elements for Silverstripe Elemental

Package info

github.com/clesson-de/silverstripe-elemental-essentials

Type:silverstripe-vendormodule

pkg:composer/clesson-de/silverstripe-elemental-essentials

Statistics

Installs: 57

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2026-11-21 07:49 UTC

This package is not auto-updated.

Last update: 2026-11-22 05:59:47 UTC


README

Essential content blocks for Silverstripe 6 and Elemental 6:

  • Text/Media: rich text, optionally accompanied by an image, video or audio file; media left, right, above or below.
  • Image: one image, optionally opening the original image in a modal.
  • Video: native controls, muted decorative playback, or a clickable preview opening a video modal.

The module uses Silverstripe-managed files, responsive scoped CSS and native HTML dialogs. It does not require Bootstrap, jQuery or external media providers.

Installation

composer require clesson-de/silverstripe-elemental-essentials
composer vendor-expose
vendor/bin/sake dev/build --flush

Alternatively, run /dev/build?flush=all in your development environment.

Elemental must already be enabled for the relevant page types. This module does not change page extensions or existing allowed-element restrictions. If your project restricts available blocks, add these classes to its existing allowed_elements configuration:

Page:
  allowed_elements:
    - Clesson\ElementalEssentials\Elements\TextMediaElement
    - Clesson\ElementalEssentials\Elements\ImageElement
    - Clesson\ElementalEssentials\Elements\VideoElement

The compiled frontend files ship with the package and are loaded only when an Essentials element renders.

Editor guide

Add an element through the usual Elemental block picker. The initial empty block is saved automatically by Elemental; subsequent saves and all publication require complete content.

Block Required content Options
Text/Media Text; matching file if a media type is selected Text only by default; media position defaults to right. Video/audio use native controls.
Image Image Alternative text; original-image modal disabled by default.
Video Video; preview image additionally required for modal mode Native controls by default; decorative or modal presentation. Preview images are optional for inline modes.

Text/Media shows all media selectors for compatibility with Elemental inline editing. Only the selected kind is displayed; other selections remain stored. Attached files are owned for publication, including retained selections. Remove unused selections when they should not be published.

Allowed image formats: JPG/JPEG, PNG, GIF and WebP. Video: MP4, WebM and OGV. Audio: MP3, M4A, OGG and WAV. Your project's upload policy may restrict these further. The module validates existing files, extensions and MIME categories; it does not transcode media. Actual browser support also depends on the codec. H.264 MP4 and MP3 are common broadly supported choices.

Use meaningful image alternative text; leave it empty only for decorative images. Supply equivalent text for important audio/video content. The module does not provide caption upload, transcripts or transcoding and does not guarantee accessibility of editorial media.

Decorative videos are muted, loop and play inline. JavaScript starts playback only when reduced motion is not requested; an accessible Play/Pause button remains available. Enabling reduced motion while playing pauses the video. Without JavaScript, native controls remain available. Modal triggers fall back to direct media links without JavaScript or native dialog support.

Closing a video modal pauses and resets playback. Playback failures are announced and native controls remain available.

Permissions and publication

Create/edit/delete/view checks delegate to Elemental and its page-aware access checks. The module adds no public media route and does not bypass protected-file access. Render elements through the normal Elemental area on published pages; draft preview remains available through Silverstripe's existing preview mechanism.

Media relations use $owns so recursive publication includes the files. Duplicating an element retains its library-file references; removing the element does not cascade-delete shared files.

Developer documentation

Templates mirror the element namespace under:

templates/Clesson/ElementalEssentials/Elements/
templates/Clesson/ElementalEssentials/Includes/

Override these templates in your theme to customise markup or image sizing. Normal images and posters use ScaleMaxWidth(1600); the image modal uses the original asset. Keep data-ee-* attributes, dialog IDs, labels and controls when using the shipped JavaScript. The surrounding Elemental holder is unchanged. If you replace an element template completely, preserve or repeat the CSS and JavaScript <% require %> directives from the original template so that its assets still load.

CSS is scoped to .ee and uses:

.ee {
  --ee-gap: 1.5rem;
  --ee-dialog-background: #fff;
  --ee-dialog-color: #111;
}

The rich-text field uses its own TextMediaElement_Body_EditorConfig, cloned from the CMS editor. Media/embed toolbar buttons are removed so media is selected in the block's dedicated fields.

Subclass elements or use normal Silverstripe extensions to customise fields, permissions and templates. Do not bypass content validation when publishing. The shared lifecycle is a trait, not an additional selectable block.

Frontend build

Node.js 22 is specified in .nvmrc. From the module directory:

nvm use
npm ci
npm run build

Rollup produces client/frontend/dist/bundle.js; Sass produces client/frontend/dist/bundle.css. Filenames are stable and referenced with <% require css(...) %> and <% require javascript(...) %> directly in the three Element templates. Run composer vendor-expose in the consuming application after rebuilding if exposed assets are not symlinked.

Use npm run build:js or npm run build:css separately. During development, run npm run watch:js and npm run watch:css in separate terminals.

Tests

From the consuming Silverstripe application's root:

vendor/bin/phpunit --bootstrap vendor/silverstripe/framework/tests/bootstrap.php silverstripe-elemental-essentials/tests

Database tests use SapphireTest's isolated database and a named temporary asset store. The tiny blue image/video and silent audio fixtures were generated specifically for these tests.

Frontend tests run with npm test in the module directory. Install the test browser first with npx playwright install chromium.

License

BSD-3-Clause.