Hi friends.
I use ACF PRO 5.7.0 and I try to upload image with acf_form.
First, create field-group and IMAGE type custom field(required : true and Maximum filesize : 2).
Next, write this code in page-image_uploader.php.
acf_form(array(
'post_id' => 'new_post',
'post_title' => true,
'fields' => array('image_description', 'uploaded_image'),
'html_after_fields' => '<input type="hidden" name="posted_post_type" value="image_uploader" />',
'return' => '%post_url%',
'uploader' => 'basic',
'new_post' => array(
'post_type' => 'uploaded_image'
),
'submit_value' => 'send'
));
Without problems In the case of images of 2MB or less.
However, if I upload images larger than 2MB, only the image will disappear but post will be created.
For images larger than 20MB(It is the upper limit of php.ini), an error is displayed and no post is created.
I tried the following code as a trial.
function my_acf_prefilter( $errors ){
var_dump($errors);
exit;
}
add_filter('acf/upload_prefilter', 'my_acf_prefilter', 10, 1);
Return this.
array(1) {
["max_size"]=>
string(36) "File size must must not exceed 2 MB."
}