ACF_Media::wp_prepare_attachment_for_js
Filters attachment data as it is being prepared for JS.
Method of the class: ACF_Media{}
No Hooks.
Returns
Array.
Usage
$ACF_Media = new ACF_Media(); $ACF_Media->wp_prepare_attachment_for_js( $response, $attachment, $meta );
- $response(array) (required)
- Array of prepared attachment data.
- $attachment(WP_Post) (required)
- Attachment object.
- $meta(array|false) (required)
- Array of attachment meta data, or false if there is none.
Changelog
| Since 5.9.7 | Introduced. |
ACF_Media::wp_prepare_attachment_for_js() ACF Media::wp prepare attachment for js code ACF 6.0.4
function wp_prepare_attachment_for_js( $response, $attachment, $meta ) {
$field = $this->get_source_field();
// Validate the attachment and append any errors.
$errors = acf_validate_attachment( $response, $field, 'prepare' );
$response['acf_errors'] = false;
if ( ! empty( $errors ) ) {
$response['acf_errors'] = implode( '<br />', $errors );
}
// Return.
return $response;
}