ACF_Media::handle_upload_prefilter() public ACF 5.1.5
description
{} Это метод класса: ACF_Media{}
Хуки из метода
Возвращает
$post_id. (int)
Использование
$ACF_Media = new ACF_Media(); $ACF_Media->handle_upload_prefilter( $file );
- $file (обязательный)
- -
Список изменений
С версии 5.1.5 | Введена. |
Код ACF_Media::handle_upload_prefilter() ACF Media::handle upload prefilter ACF 5.9.1
function handle_upload_prefilter( $file ) {
// bail early if no acf field
if( empty($_POST['_acfuploader']) ) {
return $file;
}
// load field
$field = acf_get_field( $_POST['_acfuploader'] );
if( !$field ) {
return $file;
}
// get errors
$errors = acf_validate_attachment( $file, $field, 'upload' );
/**
* Filters the errors for a file before it is uploaded to WordPress.
*
* @date 16/02/2015
* @since 5.1.5
*
* @param array $errors An array of errors.
* @param array $file An array of data for a single file.
* @param array $field The field array.
*/
$errors = apply_filters( "acf/upload_prefilter/type={$field['type']}", $errors, $file, $field );
$errors = apply_filters( "acf/upload_prefilter/name={$field['_name']}", $errors, $file, $field );
$errors = apply_filters( "acf/upload_prefilter/key={$field['key']}", $errors, $file, $field );
$errors = apply_filters( "acf/upload_prefilter", $errors, $file, $field );
// append error
if( !empty($errors) ) {
$file['error'] = implode("\n", $errors);
}
// return
return $file;
}