Download the PHP package restruct/silverstripe-asset_icons without Composer

On this page you can find all versions of the php package restruct/silverstripe-asset_icons. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package silverstripe-asset_icons

SilverStripe Asset Icons

Maintained by Restruct. If this module saves you time, you can support ongoing maintenance.

Replaces the default document thumbnails in SilverStripe's Asset Admin with category-colored SVG icons and rendered preview thumbnails. Works in AssetAdmin (grid & list view, edit panel) and UploadField modals. Handles any file extension automatically.

Requirements

Installation

Then flush (?flush=1, or sake dev/build flush=1 on Silverstripe 5 / sake db:build --flush on Silverstripe 6). The category icons work straight away; rendered previews are opt-in (below).

Version compatibility

composer.json is the source of truth; this table follows it.

Branch Module version Silverstripe PHP
main 2.4.x ^5 \|\| ^6 ^8.1 (Silverstripe 6: ^8.3)
(tags only) 2.0 - 2.3 ^5 ^8.1 (not declared; set by asset-admin 2)
(tags only) 1.x ^4 not declared; whatever Silverstripe 4 allows

Silverstripe 4 reached end of life in April 2025 and is not supported by 2.x. main is the only maintained line; a version branch is created only when a change cannot be made compatible across the supported range.

How it works

Category icons

  1. CSS immediately applies category icons using SilverStripe's built-in classes (gallery-item--document, gallery-item--archive, etc.) - no flash of default icons
  2. JavaScript reads React fiber data and sets data-ext attributes for more specific icons (e.g., PDF instead of generic document)
  3. SCSS maps ~170 file extensions to 18 categories, each with a colored SVG icon
  4. External SVGs are loaded on-demand and cached by the browser (~92KB CSS + ~34KB SVGs)

Regular images don't need icons - SilverStripe generates thumbnails for those. This module targets document-category files only.

Rendered preview thumbnails

For file types that can be rendered to images (PDFs, SVGs, EPS, etc.), the module generates actual PNG preview thumbnails instead of showing a generic category icon. Previews appear in tile view, table view, and the edit panel.

Previews are generated on-demand the first time a file appears in Asset Admin and stored as file variants in the AssetStore. A small file-type badge (e.g. "PDF") is shown on the thumbnail so users can distinguish previews from actual images.

How it works under the hood:

Enable in your project config:

Configuration options:

All options live on Restruct\SilverStripe\AssetIcons\Renderable\RenderablePreviewExtension:

Option Default Effect
enable_renderable_previews false Master switch. Off: no previews are generated or returned anywhere
preview_width / preview_height 800 / 800 Bounds passed to the renderer (only the SVG renderer uses them, see the note below)
max_renders_per_request 5 Previews generated per request; the rest render on later page loads. Existing previews are always served
renderers pdf, eps, ps, ai, svg, svgz Map of lower-case file extension to renderer class. Remove or override an entry per extension

The renderers have their own config:

Class Option Default
XpdfRenderer render_dpi 150
GhostscriptRenderer binary_path / render_dpi gs / 150
SvgRenderer binary_path rsvg-convert

A renderer whose binary is not found is skipped: those files keep their category icon. To remove the extension from File entirely:

Supported formats and their requirements:

Format Renderer Requirement
PDF XpdfRenderer Bundled via restruct/xpdf-static - no system deps
EPS, PS, AI GhostscriptRenderer System gs (Ghostscript)
SVG, SVGZ SvgRenderer System rsvg-convert (librsvg)

Using previews in templates:

The rendered preview is available as a DBFile on any File object, supporting all standard image manipulation methods:

Returns null for images (use SilverStripe's native manipulation), unsupported formats, or when previews are disabled.

From PHP, $file->RenderedPreview() returns the same DBFile (or null), and $file->getRenderedPreviewURL() just the URL. Both generate the preview on first use.

Note on preview dimensions: PDF and EPS renderers are DPI-based (default 150 DPI) and ignore the preview_width/preview_height config - the base preview is rendered at the document's native page size (e.g. ~1240x1753px for A4). The SVG renderer uses preview_width/preview_height as bounds.

Known limitations:

Categories

Category Color Extensions
pdf Red pdf
document Blue doc, docx, docm, dotx, odt, ott, rtf, txt, md, pages, wpd, wps
spreadsheet Green xls, xlsx, xlsm, xltx, ods, ots, csv, tsv, numbers
presentation Orange ppt, pptx, pptm, potx, odp, otp, key
archive Gold zip, 7z, rar, tar, gz, tgz, bz2, xz, cab, jar, war, deb, rpm
audio Purple mp3, wav, aac, flac, ogg, opus, m4a, wma, aiff, aif, mid, midi
video Magenta mp4, avi, mov, mkv, webm, flv, wmv, mpg, mpeg, m4v, 3gp, ogv, vob
code Teal js, jsx, ts, tsx, php, py, rb, java, c, cpp, cs, go, rs, swift, sh, bat, ...
markup Slate html, htm, xml, json, yaml, yml, toml, ini, cfg, css, scss, sass, less
vector Indigo ai, eps, svg
image Cyan psd, raw, cr2, cr3, nef, dng, tif, tiff, bmp, tga, xcf, indd, sketch
cad Dark Green dwg, dxf, vsd, vsdx, vdx, vst, skp, blend, 3ds, fbx, obj, stl, step, stp, iges
database Dark Blue sql, db, sqlite, sqlite3, mdb, accdb, dbf, odb
font Dark Purple ttf, otf, woff, woff2, eot, pfb, pfm
system Dark Gray exe, dll, bin, iso, dmg, app, msi, sys, apk, ipa
ebook Brown epub, mobi, azw, azw3, cbz, cbr, djvu
plc Industrial e80, lsc, zap15_1, awl, gxw, acd, s7p, ap17-20, zap18-20, scl, udt, aml, tia, ...

Adding extensions

Edit client/src/styles/asset-icons.scss:

Then rebuild: npm run build

Adding categories

  1. Create an SVG in client/icons/ (use an existing one as template)
  2. Add to $category-icons map in the SCSS
  3. Map extensions to the new category in $ext-categories
  4. Rebuild: npm run build

Icon preview screen

/admin/asset-icons-preview (CMS access required, not in the CMS menu) shows every category icon with sample extensions. Useful after editing icons or colours.

Build

After building, run composer vendor-expose to re-expose client assets.

File structure

Running the tests

The suite needs a Silverstripe project to boot. Install the module into one with a Composer path repository and "symlink": true (/tests is export-ignore, so a dist install has no tests), then run it with a manifest flush:

.github/workflows/ci.yml builds exactly such a host project per Silverstripe major.

Credits


All versions of silverstripe-asset_icons with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
silverstripe/asset-admin Version ^2 || ^3
restruct/silverstripe-simpler Version ^0 || ^1
restruct/xpdf-static Version ~1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package restruct/silverstripe-asset_icons contains the following files

Loading the files please wait ...