Git Product home page Git Product logo

acf-uppy's Introduction

License: GPL v3

ACF Uppy Field (WordPress Plugin)

ACF Uppy Field is a WordPress plugin that adds a new "Uppy" custom field to the list of fields of the Advanced Custom Fields plugin.
This "Uppy" custom field allows you to overcome the limits of the default "File" field present in ACF, and to upload files of all types and sizes via the TUS protocol and the Uppy JS uploader, regardless of the limits set on the server side (there is no need to increase INI parameters like upload_max_filesize, post_max_size, max_execution_time, memory_limit, etc.).

Requirements

Recommendations

Features

  • use official Advanced Custom Fields - Field Type Template
  • use TUS protocol
  • use Uppy JS uploader
  • made with Vanilla JS (no jQuery)
  • autoload classes with Composer and PSR-4
  • assets built with Webpack
  • support ACF nested repeater
  • no limits by default for upload file size and types
  • support setting per-field size limit, mime-types and upload path
  • support uploads outside public directory (for private files)
  • download file using symlinks (no memory problems with large downloads)
  • many WP hooks available

Installation

  1. Copy the acf-uppy folder into your wp-content/plugins or wp-content/mu-plugins folder.

  2. Run this command inside the acf-uppy folder:

    $ composer install

    Alternatively, if you don't have shell access to your hosting space, read here.

  3. Activate the Advanced Custom Fields: Uppy plugin via the plugins admin page.

  4. Create a new field via ACF and select the Uppy type.

  5. Read the description above for advanced usage instructions.

Actions

do_action( 'acf_uppy/download_fallback', $postId );
  • $postId (int): The ID of the post containing ACF Uppy Field.
do_action( 'acf_uppy/download_fallback/type={$postType}', $postId );
  • $postId (int): The ID of the post containing ACF Uppy Field.
  • $postType (string): The type of the post containing ACF Uppy Field.

Filters

apply_filters( 'acf_uppy/dest_path', $destPath );
  • $destPath (string): The file destination absolute base path.
    Default: {ABSPATH}wp-content/uploads/acf-uppy.
apply_filters( 'acf_uppy/dest_path/type={$postType}', $destPath, $postId, $field );
  • $destPath (string): The file destination absolute base path.
    Default: {ABSPATH}wp-content/uploads/acf-uppy.
  • $postType (string): The type of the post containing ACF Uppy Field.
  • $postId (int): The ID of the post containing ACF Uppy Field.
  • $field (array): The field array holding all the field options.
apply_filters( 'acf_uppy/tmp_path', $tmpPath );
  • $tmpPath (string): The file temporary absolute path.
    Default: {sys_get_temp_dir()}/acf-uppy/{get_current_user_id()}.
apply_filters( 'acf_uppy/symlink_url', $symlinkUrl );
  • $symlinkUrl (string): The symlinks absolute base url.
    Default: {site_url()}/wp-content/plugins/acf-uppy/symlink.
apply_filters( 'acf_uppy/symlink_path', $symlinkPath );
  • $symlinkPath (string): The symlinks absolute base path.
    Default: {ABSPATH}wp-content/plugins/acf-uppy/symlink.
apply_filters( 'acf_uppy/base_path', $basePath );
  • $basePath (string): The base url endpoint.
    Default: acf-uppy.
apply_filters( 'acf_uppy/api_path', $apiPath );
  • $apiPath (string): The TUS base url endpoint.
    Default: wp-tus.
apply_filters( 'acf_uppy/cache', $cacheType );
  • $cacheType (string): The TUS cache type.
    Options: redis, apcu or file.
    Default: file.
apply_filters( 'acf_uppy/cache_ttl', $cacheTtl );
  • $cacheTtl (string): The TUS cache TTL in secs.
    Default: 86400.
apply_filters( 'acf_uppy/file_name_exists', $fileName, $destPath, $pathinfo, $counter );
  • $fileName (string): The file name renamed.
    Default: {$pathinfo['filename']}-{$counter}.{$pathinfo['extension']}.
  • $destPath (string): The directory absolute path to the file.
  • $pathinfo (array): The pathinfo of the file.
  • $counter (int): The incremented counter.
apply_filters( 'acf_uppy/file_name', $fileName, $destPath );
  • $fileName (string): The file name.
  • $destPath (string): The directory absolute path to the file.
apply_filters( 'acf_uppy/download_hash', $hash, $destFile, $postId );
  • $hash (int|string): The hash used in download url.
    Default: wp_hash( $destFile ).
  • $destFile (string): The absolute path of the file.
  • $postId (int): The ID of the post containing ACF Uppy Field.
apply_filters( 'acf_uppy/download_hash/type={$postType}', $hash, $destFile, $postId );
  • $hash (string): The hash used in download url.
    Default: wp_hash( $destFile ).
  • $postType (string): The type of the post containing ACF Uppy Field.
  • $destFile (string): The absolute path of the file.
  • $postId (int): The ID of the post containing ACF Uppy Field.
apply_filters( 'acf_uppy/download_allow', $allow, $destFile, $postId );
  • $allow (bool): Whether or not to allow the file download.
  • $destFile (string): The absolute path of the file.
  • $postId (int): The ID of the post containing ACF Uppy Field.
apply_filters( 'acf_uppy/download_allow/type={$postType}', $allow, $destFile, $postId );
  • $allow (bool): Whether or not to allow the file download.
  • $postType (string): The type of the post containing ACF Uppy Field.
  • $destFile (string): The absolute path of the file.
  • $postId (int): The ID of the post containing ACF Uppy Field.
apply_filters( 'acf_uppy/download_symlink_delete_days', $days );
  • $days (int): Number of days before old symlinks are deleted.
    Default: 1.
apply_filters( 'acf_uppy/download_symlink_delete_max', $max );
  • $max (int): How many old symlinks need to be deleted on each request.
    Default: 10.

Webpack tasks

  • Build sources:

    $ npm run develop
  • Start file watcher for recompiling:

    $ npm run watch
  • Build sources for production:

    $ npm run production

Changelog

See auto-CHANGELOG file.

Roadmap

  1. Add support for Uppy fields associated with WP users.
  2. Test PHP 8.x.

Do you need other features? Send me a new enhancement!

Contributing

For your contributions please use the git-flow workflow.

Support

Buy Me A Coffee

Usefull links

License

(ษ”) Copyleft 2021 Frugan GNU GPLv3, see COPYING file.

acf-uppy's People

Contributors

frugan-dev avatar fullbl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

acf-uppy's Issues

Error 404 on upload

Hi,
I have a problem uploading a file using a permalink rule different from: "Post Name".
When i use a permalink with custom structure like "/blog/%category%/%postname%/" the upload return a http 404 Error on wp-tus upload call.

Many thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.