Skip to main content

Self-hosted assets

By default, all Javascript and CSS assets are loaded from the JsDelivr CDN. This ensures that assets load fast regardless of the visitor's geographic location, and that Files gallery remains portable in a single file. In some cases however, it may be beneficial to self-host the assets on your own server.

  • Allow Files gallery to work without internet connection.
  • If JsDelivr CDN is slow or unreliable, for instance inside China.
  • For other privacy reasons.

Instructions

1. Download assets

Download assets ZIP that corresponds with your Files gallery version. For instance, if you are using version 0.6.0, use the download link below. If you are using another version, replace 0.6.0 with your version number. It's important that you download assets that match the version you are using, since the assets included will depend on the Files gallery version and may change with new versions.

https://cdn.jsdelivr.net/npm/files.photo.gallery@0.6.0/_files/assets/assets.zip

2. Unzip

Unzip the assets.zip so all assets are contained inside _files/assets relative to your Files gallery installation. Your dir would look something like this:

├── _files
│ └── assets
│ ├── file-saver@2.0.5
│ ├── @uppy
│ ├── files.photo.gallery@0.6.0
│ └── ...

3. Assign assets config option

Finally, point the assets config option to your _files/assets dir. This will effectively cause Files gallery to load all assets from this location instead of from the jsDelivr CDN.

'assets' => '_files/assets',
Upgrading

Whenever you upgrade Files gallery, you will need to repeat steps #1 and #2

Alternative asset paths

The path _files/assets is the recommended location to store Files gallery assets, but you could use an entirely different path. For instance if you have multiple Files gallery installations on your server, you may want to serve assets from a shared location. Some examples:

// serve assets from an absolute location on your host, which may then be re-used for multiple Files gallery installations.
'assets' => '/files_assets',

// basically the same as above, but includes the hostname, in which case you could share the assets for multiple Files gallery installations across different domains.
'assets' => 'https://yourhost.com/files_assets',

// You could also use paths relative to your Files gallery installation.
'assets' => '../../files_assets',

// You could also upload assets to your own CDN service.
'assets' => 'https://files.alicdn.com/assets',

// Or simply re-assign the default CDN url from cdn.jsdelivr.net to fastly.jsdelivr.net. This is a nice trick for example if China decides to temporarily block one domain but not the other
'assets' => 'https://fastly.jsdelivr.net/npm',