为某些POST类型设置jpeg_quality

时间:2012-01-17 作者:Lane

如果不使用timthumb,是否有人知道如何为某些帖子类型或帖子设置jpeg\\U质量?

2 个回复
SO网友:Chris_O

你可以在jpeg_quality filter 并检查要对其应用筛选器的帖子类型。

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

endif;

 }

SO网友:RichardTape
add_filter( \'jpeg_quality\', \'wpse_39179_jpeg_quality_for_post_type\' );

function wpse_39179_jpeg_quality_for_post_type( $quality ) {

    if ( ( isset($_GET[\'post_type\'] ) && $_GET[\'post_type\'] == \'post_type_slug\' ) || ( isset( $post_type ) && $post_type == \'post_type_slug\' ) ){

        // For this post type, we want 100% quality
        return \'100\';

    }else{

        // Otherwise, revert back to what was passed into this filter to allow us to modify it elsewhere
        return $quality;

    }

}/* wpse_39179_jpeg_quality_for_post_type() */
结束

相关推荐

images are broken

我有一段代码,用于显示来自RSS提要的每篇帖子上的图像,这些图像将从yahoo images search获取,我将把这段代码粘贴到我的单曲中。php文件,这样它就会出现在我的帖子之后,我在其中一个网站上找到了这段代码,这段代码用于获取图像,但不是从yahoo获取图像,而是从不同的feed获取图像我使用的代码如下:- <?php include_once(ABSPATH.WPINC.\'/rss.php\'); // path to include script $f