Skip to main content
  Tuesday, April 23 2019
  4 Replies
  4.8K Visits
  Subscribe
Hello,

I'm using a wordpress with the WP Media Folder plugin. It's working really nice, except for one thing.

I recently changed the Wordpress image compression function, in order to have a better image quality (i'm compressing them by myself). My function is working when I upload an image into the library, but when I choose the "Send new file and replace" option, I can see the compression is still applied.

I already looked into the plugin code, but I don't see where the function is used, or where it can be change... So the question is simple, how can I change the compression rate and have no compression when I use "Send new file and replace" option ?

Hope you can help.

Toasch
A
5 years ago
Hi,

Thanks for contacting us here about this extension.
I recently changed the Wordpress image compression function, in order to have a better image quality (i'm compressing them by myself). My function is working when I upload an image into the library, but when I choose the "Send new file and replace" option, I can see the compression is still applied.

I already looked into the plugin code, but I don't see where the function is used, or where it can be change... So the question is simple, how can I change the compression rate and have no compression when I use "Send new file and replace" option ?

I'm not sure what includes in your function, anyway you can take a look at these files for more information:
wp-media-folder/class/class-replace-file.php
wp-media-folder/class/class-helper.php

Hope it helps!
Cheers,
T
5 years ago
Hi,

Thank you for replying.

I include this function :
add_filter('jpeg_quality', function($arg){return 100;});

into the "functions.php" file. I thought I would find something very similar into the files you told me to check, but I don't see where this function is... I suppose my skills in PHP aren't good enough.

Anyway, thanks for trying to solve but I supposed I'm on my own for this one...
A
5 years ago
Hi,

Thanks for getting back to me with more information.
how can I change the compression rate and have no compression

I'm not sure what do you mean exactly. As I know you want to remain the same image quality when using "Send new file and replace" option.
If that what you need, please try the following code in "/wp-media-folder/class/class-helper.php" line 58:

imagejpeg( $tmp_img, path_join($uploadpath['basedir'], $intermediate_file), apply_filters( 'jpeg_quality', 100, 'replace_image' ) );


Hope it helps!
Cheers,
T
5 years ago
Hi,

Awesome, that was exactly what I needed. Thank you very much for your help !

Have a nice day
  • Page :
  • 1
There are no replies made for this post yet.