Title: jpeg_quality
Published: April 25, 2014
Last modified: August 20, 2026

---

# apply_filters( ‘jpeg_quality’, int $quality, string $context )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#user-contributed-notes)

Filters the JPEG compression quality for backward-compatibility.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#description)󠁿

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

The [WP_Image_Editor::set_quality()](https://developer.wordpress.org/reference/classes/wp_image_editor/set_quality/)
method has priority over the filter.

The filter is evaluated under two contexts: ‘image_resize’, and ‘edit_image’, (when
a JPEG image is saved to file).

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#parameters)󠁿

 `$quality`int

Quality level between 0 (low) and 100 (high) of the JPEG.

`$context`string

Context of the filter.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#source)󠁿

    ```php
    $quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-image-editor.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-image-editor.php#L288)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-image-editor.php#L288-L288)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_get_image_encode_quality()](https://developer.wordpress.org/reference/functions/wp_get_image_encode_quality/)`wp-includes/media.php` |

Determines the encode quality WordPress would use for an image.

  | 
| [wp_save_image_file()](https://developer.wordpress.org/reference/functions/wp_save_image_file/)`wp-admin/includes/image-edit.php` |

Saves image to file.

  | 
| [WP_Image_Editor::set_quality()](https://developer.wordpress.org/reference/classes/wp_image_editor/set_quality/)`wp-includes/class-wp-image-editor.php` |

Sets Image Compression quality on a 1-100% scale.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#comment-content-1935)
 2.    [behzadg](https://profiles.wordpress.org/behzadg/)  [  10 years ago  ](https://developer.wordpress.org/reference/hooks/jpeg_quality/#comment-1935)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fjpeg_quality%2F%23comment-1935)
     Vote results for this note: 3[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fjpeg_quality%2F%23comment-1935)
 4.  To change JPEG Compression, temporarily add the below code to functions.php then
     refresh the site to re-compress all thumbnails on the site.
 5.      ```php
         function my_prefix_regenerate_thumbnail_quality() {
         	return 80;
     
         }
     
         add_filter( 'jpeg_quality', 'my_prefix_regenerate_thumbnail_quality');
         ```
     
 6.   * “Refresh(ing) the site” is not going to recompress the images. For this you’ll
        need to regenerate all thumbnails and derived sizes using a plugin for this
        purpose.
      * [theMikeD](https://profiles.wordpress.org/themiked/) [4 years ago](https://developer.wordpress.org/reference/hooks/jpeg_quality/#comment-6022)
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fjpeg_quality%2F%3Freplytocom%3D1935%23feedback-editor-1935)
 8.   [Skip to note 5 content](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#comment-content-1916)
 9.    [Emil Uzelac](https://profiles.wordpress.org/emiluzelac/)  [  10 years ago  ](https://developer.wordpress.org/reference/hooks/jpeg_quality/#comment-1916)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fjpeg_quality%2F%23comment-1916)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fjpeg_quality%2F%23comment-1916)
 11. Snippets should be included here, not hosted elsewhere.
 12.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fjpeg_quality%2F%3Freplytocom%3D1916%23feedback-editor-1916)
 13.  [Skip to note 6 content](https://developer.wordpress.org/reference/hooks/jpeg_quality/?output_format=md#comment-content-1576)
 14.   [Rami Yushuvaev](https://profiles.wordpress.org/ramiy/)  [  11 years ago  ](https://developer.wordpress.org/reference/hooks/jpeg_quality/#comment-1576)
 15. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fjpeg_quality%2F%23comment-1576)
     Vote results for this note: -10[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fjpeg_quality%2F%23comment-1576)
 16. Changing the JPEG compression quality:
 17. [https://generatewp.com/snippet/xNM817E/](https://generatewp.com/snippet/xNM817E/)
 18.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fjpeg_quality%2F%3Freplytocom%3D1576%23feedback-editor-1576)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fjpeg_quality%2F)
before being able to contribute a note or feedback.