Download the PHP package lekoala/silverstripe-filepond without Composer

On this page you can find all versions of the php package lekoala/silverstripe-filepond. 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-filepond

SilverStripe FilePond module

Build Status scrutinizer Code coverage

Intro

Allow usage of FilePond fields in the front end.

Use as a regular UploadField and let it do its magic!

File extension

In order for this uploader to work properly, your files need to have a IsTemporary boolean field. This is provided by the FilePondFileExtension class.

You can of course implement your own extension. As a bonus, you can toggle the enable_auto_thumbnails to true in order to get thumbnails for images in the cms.

Temporary files

Because files are upload in ajax, maybe they will never be used if the user never submit the form.

In order to avoid storing unecessary files, all files uploaded are flagged by default as IsTemporary.

All files are then unflagged as IsTemporary when the form is submitted and saved into a record.

Although this should all work automatically, if you manually use the FilePondField without saving into a record you need to manually unflag the files yourself.

By default, old temporary files are deleted automatically by the FilePondField::clearTemporaryUploads method. You can control how often files are deleted based on your upload frequencies (see auto_clear_threshold). Since the files are deleted on upload, it might take some time if you have a lot of files to delete. This is disabled by default and you need to enable it with auto_clear_temp_folder set to true

If that's the case, maybe it's better to run a cron task every 5 minutes that calls this method in order to avoid burdening the end user. Have a look at my simple jobs module to do that.

Tracking files

Most of the time, uploaded files are linked to a record. The primary mechanism of moving uploaded files out of the IsTemporary state is done through the FilePondField::saveInto method.

In order to maximize tracking, the FilePondFileExtension also add ObjectID and ObjectClass fields to the File table.

This allows to associate files easily to your DataObject classes without adding specific has_many or many_many relations, which either create extra tables or required reciprocal relationships.

Instead, while moving files out of IsTemporary state, we also associate the current form record to the file.

Configuring field instances

This module configure FilePondFields based on a config data attribute. It will generate most of the config by itself, however you can customize frontend behaviour with the following method:

Please refer to FilePond documentation to see what are the public properties.

Poster images

You can enable dedicated plugins

These modules enable poster support to display nices images attached to the upload field

Validation, resizing and croping

For files

By default, this module validate file size and file extension in the front end thanks to the FilePond plugins.

You can read more here:

https://pqina.nl/filepond/docs/patterns/plugins/file-validate-size/ https://pqina.nl/filepond/docs/patterns/plugins/file-validate-type/

For images

We also installed the image size validation, resize and crop plugins. This allows to avoid user uploading incorrect format that might be difficult to crop or resize (GD crashing anyone?).

You can define custom image sizes on your records based on convention. For example, for a squared avatar and a large image.

Parameters are width, height. You can set a 3rd parameter to:

Image manipulations happen on the client side, the file that gets sent to the server will have the configured size. Very useful to deal with large images or avoiding scaling files after upload.

If defined, the field description and the validation will be automatically applied.

You can also use the setImageSize method directly on the uploader instance with similar parameters.

You can read more here:

https://pqina.nl/filepond/docs/patterns/plugins/image-validate-size/ https://pqina.nl/filepond/docs/api/plugins/image-resize/ https://pqina.nl/filepond/docs/api/plugins/image-crop/

Renaming and organizing files

One thing is certain, your user tends to name files incorrectly. The end result is that your asset folder is full of stuff with crazy names.

In order to bring some sanity to your asset folder, this module work in two ways.

Default folder

The default behaviour from SilverStripe is to upload everything in the Uploads folder. But wouldn't it be more useful to organize things based on your class ? Project files go to Project folder. Sounds good?

Great, because this is exactly how it works.

By default, if a record is associated to the form, all files will be uploaded to NameOfTheClass/NameOfTheUploader.

This behaviour is fully configurable. If your DataObject implements a getFolderName method, you can retain paths based on your own logic (for example NameOfTheClass/IDOfTheRecord). By default, I don't recommend to store files based on records IDs because : 1. IDs are not known for new records, 2. If you have lots of records, you will have lots of folders that are slow to parse and display.

Renaming files according to a pattern

Let's say your users can upload avatars. But it wouldn't be too good to allow crazy names in a public facing website right?

Don't worry, I'm here to help:

By setting a rename pattern, you can rename dynamically the files before they are saved to the asset store (which is really great).

The following pattern will rename the file to Avatar_yyyymmdd.jpg. You can also set static parts, for example:

You can also use the built-in Filepond renamer like this. Files will be renamed in the frontend before being upload to the server:

Chunked uploads

If you need to upload large videos, you can use setChunkUploads. File will be uploaded in chunks (size is computed automatically based on server settings) and then merged on the last upload.

You can also enable this globally with chunk_by_default.

Requirements

In order to provide a working out of the box experience, Filepond is provided as a custom element imported from https://github.com/lekoala/formidable-elements

Custom server config

If for some reason you use a custom endpoint for your FilePond, you can use the setCustomServerConfig. You can pass an array of options (for simple configs) or a string that should be the name of a global js handler.

Config flags

FilePondField has the following configurable options

Todo

Sponsored by

This module is kindly sponsored by RESTRUCT

Compatibility

Tested with 4.5 to 4.13 but should work on any 4.x projects

Maintainer

LeKoala - [email protected]


All versions of silverstripe-filepond with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8
silverstripe/framework Version ^4 || ^5
silverstripe/assets Version ^1.6 || ^2
silverstripe/versioned Version ^1.6 || ^2
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 lekoala/silverstripe-filepond contains the following files

Loading the files please wait ....