Flypress
WIP - Requires PHP 7.0 and WordPress 4.6, (*1)
Use Flysystem with WordPress. Flypress will rename each file uploaded to WordPress with a new name based on uuid v4, the attachment title will not be changed to uuid., (*2)
Installation
composer require isotopsweden/wp-flypress
Usage
Example configuration for using the built in adapter for AWS S3 with Minio locally. Region and endpoint constant is optional., (*3)
/* Flypress */
define( 'FLYPRESS_ADAPTER', 'aws-s3' );
/* AWS S3 */
define( 'AWS_S3_ENDPOINT', 'http://localhost:9999/' );
define( 'AWS_S3_BUCKET_URL', 'http://localhost:9999/bwh' );
define( 'AWS_S3_BUCKET', 'bwh' );
define( 'AWS_S3_KEY', 'key' );
define( 'AWS_S3_SECRET', 'secret' );
define( 'AWS_S3_REGION', 'us-east-1' );
Custom adapter
Add a custom adapter to flypress using flypress_adapter
filter., (*4)
add_filter( 'flypress_adapter', function () {
return new \League\Flysystem\Adapter\Local( '/path/to/folder' );
} );
With flypress_upload_url
can you modify how the base url of a upload url looks like., (*5)
add_filter( 'flypress_upload_url', function () {
return 'http://localhost:9000/';
} );
Look at the built in aws-s3
adapter to check how we created a working flypress adapter and if you look at the source code for flypress you will find some more filters that you can hook into., (*6)
WP-CLI
-
wp flypress test
- test if flysystem and flypress works, it will write, read and delete a file on the used adapter. Useful it you would like to test if AWS S3 connection is working or not.
-
wp flypress migrate [--delete-local]
- migrates all images to flysystem with a optional flag to delete local attachment if any.
Todo
License
MIT © Isotop, (*7)