wc_prepare_attachment_for_js

Prepare attachment for JavaScript.

Description

(array) wc_prepare_attachment_for_js( (array) $response ); 

Returns (array)

Parameters (1)

0. $response (array)
The response.

Usage

  1. if ( !function_exists( 'wc_prepare_attachment_for_js' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-product-functions.php'; 
  3.  
  4. // The response. 
  5. $response = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_prepare_attachment_for_js($response); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-product-functions.php  
  1. function wc_prepare_attachment_for_js( $response ) { 
  2.  
  3. if ( isset( $response['url'] ) && strstr( $response['url'], 'woocommerce_uploads/' ) ) { 
  4. $response['full']['url'] = wc_placeholder_img_src(); 
  5. if ( isset( $response['sizes'] ) ) { 
  6. foreach ( $response['sizes'] as $size => $value ) { 
  7. $response['sizes'][ $size ]['url'] = wc_placeholder_img_src(); 
  8.  
  9. return $response;