Skip to content

Commit

Permalink
- Smoother Gutenberg editor support with a custom error message direc…
Browse files Browse the repository at this point in the history
…ting to use the media library uploader.
  • Loading branch information
uglyrobot committed Feb 3, 2022
1 parent c50114f commit 39ebf5c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
14 changes: 14 additions & 0 deletions assets/js/block-notice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { __ } = wp.i18n;

function BFUGettextFilter( translation, text, domain ) {
if ( text === 'This file exceeds the maximum upload size for this site.' ) {
return translation + ' ' + __('To upload larger files use the upload tab via the Media Library link.', 'tuxedo-big-file-uploads');
}
return translation;
}

wp.hooks.addFilter(
'i18n.gettext',
'infinite-uploads/bfu/upload-notice',
BFUGettextFilter
);
5 changes: 3 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Contributors: uglyrobot, jdailey, andtrev
Tags: increase file size limit, increase upload limit, max upload file size, post max size, upload limit, file upload, files uploader, ftp, video uploader, AJAX
Requires at least: 5.3
Tested up to: 5.9
Stable tag: 2.0.1
Stable tag: 2.0.2
Requires PHP: 5.5
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -111,12 +111,13 @@ No. [Infinite Uploads](https://wordpress.org/plugins/infinite-uploads/) is an op

== Changelog ==

2.0.2 - 2022-1-31
2.0.2 - 2022-2-03
----------------------------------------------------------------------
- Fix: Conflicts with some theme builders like Themify.
- Fix: Fail with error message instead of showing success with partially uploaded big files missing chunks.
- Optimize default chunk size to limit requests.
- Add a review on wordpress.org timed notice
- Smoother Gutenberg editor support with a custom error message directing to use the media library uploader.

2.0.1 - 2021-6-30
----------------------------------------------------------------------
Expand Down
34 changes: 33 additions & 1 deletion tuxedo_big_file_uploads.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Big File Uploads
* Description: Enable large file uploads in the built-in WordPress media uploader via multipart uploads, and set maximum upload file size to any value based on user role. Uploads can be as large as available disk space allows.
* Version: 2.0.2-beta-1
* Version: 2.0.2
* Author: Infinite Uploads
* Author URI: https://infiniteuploads.com/?utm_source=bfu_plugin&utm_medium=plugin&utm_campaign=bfu_plugin&utm_content=meta
* Network: true
Expand Down Expand Up @@ -109,6 +109,9 @@ public function __construct() {
//add_filter( 'ext2type', array( $this, 'filter_ext_types' ) );
add_action( 'wp_ajax_bfu_chunker', array( $this, 'ajax_chunk_receiver' ) );
add_action( 'post-upload-ui', array( $this, 'upload_output' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'gutenberg_notice' ) );
add_filter( 'block_editor_settings_all', array( $this, 'gutenberg_size_filter' ) );


//single site
add_action( 'admin_menu', [ &$this, 'admin_menu' ] );
Expand Down Expand Up @@ -258,6 +261,35 @@ public function temp_available_size() {
return $bytes;
}

/**
* Add the js to Gutenberg to add our custom upload size notice.
*
* @return void
*/
function gutenberg_notice() {
wp_enqueue_script(
'bfu-block-upload-notice',
plugin_dir_url( __FILE__ ) . 'assets/js/block-notice.js',
[ 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ],
BIG_FILE_UPLOADS_VERSION
);

wp_set_script_translations( 'bfu-block-upload-notice', 'tuxedo-big-file-uploads' );
}

/**
* Always pass the original size limit to Gutenberg so it can show our error (BFU only works inside media library via plupload).
*
* @param $editor_settings
*
* @return mixed
*/
function gutenberg_size_filter( $editor_settings ) {
$editor_settings['maxUploadFileSize'] = $this->max_upload_size;

return $editor_settings;
}

/**
* Enqueue html on the upload form.
*
Expand Down

0 comments on commit 39ebf5c

Please sign in to comment.