wp_editor_set_quality
Filters the default image compression quality setting.
Description
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.
- $this_default_quality = apply_filters( 'wp_editor_set_quality', $this_default_quality, $this_mime_type );
- if ( !empty( $this_default_quality ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the wp_editor_set_quality callback
- function filter_wp_editor_set_quality( $this_default_quality, $this_mime_type ) {
- // make filter magic happen here...
- return $this_default_quality;
- };
- // add the filter
- add_filter( 'wp_editor_set_quality', 'filter_wp_editor_set_quality', 10, 2 );
- To remove a hook callback, use the example below.
- // remove the filter
- 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
- $quality = apply_filters( 'wp_editor_set_quality', $this->default_quality, $this->mime_type );