Make Wordpress compress full size image?

Regardless of size uploaded, I need Wordpress to compress the original full size image to 30% upon upload. Full size is the only image I use.

I have already disabled all thumbnail creation upon upload. I have added a filter to change the compression of thumbnails to 30%.

add_filter('jpeg_quality', function($arg){return 30;});

However, as you know, the original upload is not compressed but retained as the full size original. I want to compress it and either create a new thumbnail of the same dimensions (if I must) or ideally, overwrite the original full size image with the compressed version.

Any ideas other than plugins? I already have a functionality plugin I keep with all my custom functions. I would like to add the solution to that plugin if possible.

Thanks!

Topic compression uploads Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.