wp_editor_set_quality

Filters the default image compression quality setting.

Description

apply_filters( 'wp_editor_set_quality', (int) $this_default_quality, (string) $this_mime_type ); 

Applies only during initial editor instantiation, or when set_quality() is run manually without the $quality argument.

set_quality() has priority over the filter.

Parameters (2)

0. $this_default_quality (int)
Quality level between 1 (low) and 100 (high).
1. $this_mime_type (string)
The this mime type.

Usage

To run the hook, copy the example below.
  1. $this_default_quality = apply_filters( 'wp_editor_set_quality', $this_default_quality, $this_mime_type ); 
  2.  
  3. if ( !empty( $this_default_quality ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_editor_set_quality callback 
  2. function filter_wp_editor_set_quality( $this_default_quality, $this_mime_type ) { 
  3. // make filter magic happen here... 
  4. return $this_default_quality
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wp_editor_set_quality', 'filter_wp_editor_set_quality', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wp_editor_set_quality', 'filter_wp_editor_set_quality', 10, 2 ); 

Defined (1)

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

/wp-includes/class-wp-image-editor.php  
  1. $quality = apply_filters( 'wp_editor_set_quality', $this->default_quality, $this->mime_type );