isotopsweden/wp-flypress

Use Flysystem with WordPress

Installs: 9

Dependents: 0

Suggesters: 0

Security: 0

Stars: 7

Watchers: 2

Forks: 0

Open Issues: 1

Type:wordpress-muplugin

dev-master 2017-02-09 12:06 UTC

This package is auto-updated.

Last update: 2022-07-29 01:21:41 UTC


README

WIP - Requires PHP 7.0 and WordPress 4.6

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.

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.

/* 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.

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.

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.

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

  • Fix so sizes works

License

MIT © Isotop