Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show max upload size message in KB if less than 1 MB, support decimal MB. #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions acf-image-aspect-ratio-crop.php
Original file line number Diff line number Diff line change
Expand Up @@ -925,14 +925,22 @@ public function rest_api_upload_callback(WP_REST_Request $data)
!empty($max_size) &&
$data->get_file_params()['image']['size'] > $max_size * 1000000
) {
// Convert to appropritate size unit
$unit = 'megabytes';
if($max_size < 1) {
$unit = 'kilobytes';
$max_size *= 1024;
}

return new WP_Error(
'file_too_large',
sprintf(
__(
'File size too large. Maximum file size is %d megabytes.',
'File size too large. Maximum file size is %g %s.',
'acf-image-aspect-ratio-crop'
),
$max_size
$max_size,
$unit
),
'acf-image-aspect-ratio-crop'
);
Expand Down