Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Without using timthumb, does anyone know of a way to set jpeg_quality for certain post-types or posts?

share|improve this question
add comment

1 Answer

You can hook into the jpeg_quality filter and do a check for the post type you want to apply the filter to.

add_filter( 'jpeg_quality', 'my_jpeq_quality' );
function my_jpeg_quality( $quality ) { 
if ((isset($_GET['post_type']) && $_GET['post_type'] == 'your_post_type') || (isset($post_type) && $post_type == 'your_post_type')) :

return 100;  //Set quality here


share|improve this answer
hmmm... this code works, however all images that aren't 'your_post_type' are now being generated with extremely low quality. (a 444k image is now 4k!) I tried adding an "else return 90" but this seems to get ignored... ` add_filter( 'jpeg_quality', 'my_jpeq_quality' ); function my_jpeg_quality( $quality ) { if ((isset($_GET['post_type']) && $_GET['post_type'] == 'work') || (isset($post_type) && $post_type == 'work')) { return 100; //Set quality }else return 90; } –  Lane Feb 14 '12 at 5:28
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.