_wp_image_editor_choose

Tests which editors are capable of supporting the request.

Description

(string|false) _wp_image_editor_choose( (array) $args = array() ); 

Returns (string|false)

Class name for the first editor that claims to support the request. False if no editor claims to support the request.

Parameters (1)

0. $args — Optional. (array) => array()
Array of arguments for choosing a capable editor. Default empty array.

Usage

  1. if ( !function_exists( '_wp_image_editor_choose' ) ) { 
  2. require_once ABSPATH . WPINC . '/media.php'; 
  3.  
  4. // Optional. Array of arguments for choosing a capable editor. Default empty array. 
  5. $args = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _wp_image_editor_choose($args); 
  9.  

Defined (1)

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

/wp-includes/media.php  
  1. function _wp_image_editor_choose( $args = array() ) { 
  2. require_once ABSPATH . WPINC . '/class-wp-image-editor.php'; 
  3. require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php'; 
  4. require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php'; 
  5. /** 
  6. * Filters the list of image editing library classes. 
  7. * @since 3.5.0 
  8. * @param array $image_editors List of available image editors. Defaults are 
  9. */ 
  10.  
  11. foreach ( $implementations as $implementation ) { 
  12. if ( ! call_user_func( array( $implementation, 'test' ), $args ) ) 
  13. continue; 
  14.  
  15. if ( isset( $args['mime_type'] ) && 
  16. ! call_user_func( 
  17. array( $implementation, 'supports_mime_type' ),  
  18. $args['mime_type'] ) ) { 
  19. continue; 
  20.  
  21. if ( isset( $args['methods'] ) && 
  22. array_diff( $args['methods'], get_class_methods( $implementation ) ) ) { 
  23. continue; 
  24.  
  25. return $implementation; 
  26.  
  27. return false;