ACF_Media::handle_upload_prefilter()
Filters data for the current file being uploaded.
Метод класса: ACF_Media{}
Хуки из метода
Возвращает
Массив
.
Использование
$ACF_Media = new ACF_Media(); $ACF_Media->handle_upload_prefilter( $file );
- $file(массив) (обязательный)
- An array of data for a single file.
Список изменений
С версии 5.1.5 | Введена. |
Код ACF_Media::handle_upload_prefilter() ACF Media::handle upload prefilter ACF 6.0.4
public function handle_upload_prefilter( $file ) { $field = $this->get_source_field(); if ( ! $field ) { return $file; } // Validate the attachment and append any 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 errors. if ( ! empty( $errors ) ) { $file['error'] = implode( "\n", $errors ); } // Ensure newly uploaded image contains "preview_size" within the "size" data. add_filter( 'image_size_names_choose', array( $this, 'image_size_names_choose' ), 10, 1 ); // Return. return $file; }