Override Options

As you may have noticed, EWWW IO has a lot of ways that you can override the default behavior. With version 3.6.0 that ability expands dramatically. It is now possible to override any setting that is a boolean (true/false) or an integer (non-decimal number) by defining the constant with the same name. This can be particularly helpful for some settings that have been removed from the settings interface due to the small number of sites using them.

First of all, let's see an example of how this works. To override anything within the EWWW IO plugin, you define a "constant" in your wp-config.php file. This is the file where your database connection details are stored, as well as a few other settings that are global within WordPress. The wp-config.php file is located right in the root of your WordPress install folder, often right inside the public_html folder or a similar location. Defining a constant looks something like this:


So here the option name is normally 'ewww_image_optimizer_delay', but it is in all-caps, which is typical for constants within PHP and WordPress. The Bulk Delay setting makes the bulk optimizer and scheduled optimizer "sleep" for 5 seconds in between images. This helps to avoid overloading a server, and can be very useful on shared hosting. The setting can also be changed directly on the Bulk Optimizer page, which is why it is being removed from the settings page.

Here are a few other settings that have been removed from the settings page, but that can still be defined as constants:

EWWW_IMAGE_OPTIMIZER_NOAUTO - Use this option to turn off automatic optimization of your images. You can optimize them manually, or using Scheduled optimization instead. This setting was removed from the settings page a long time ago, but is still used in the code and can now be turned on with a constant instead of having to mess with your database options.

EWWW_IMAGE_OPTIMIZER_OPTIPNG_LEVEL - While the default is 2, you can decrease that if large PNG files are taking too long, or you can increase it to 3 or 4 to scrape every last byte off your PNG images.

EWWW_IMAGE_OPTIMIZER_PNGOUT_LEVEL - The default here is again 2, and it has a reverse scale: 3 is lowest compression, 0 is the highest.

EWWW_IMAGE_OPTIMIZER_DISABLE_PNGOUT - Set this to false to enable use of the PNGOUT compression tool. It can't be bundled with the plugin, but you can install it manually in the wp-content/ewww/ folder.

EWWW_IMAGE_OPTIMIZER_SKIP_SIZE - Number of bytes, any image smaller than this number will not be optimized. Set to 0 to disable it.

EWWW_IMAGE_OPTIMIZER_SKIP_PNG_SIZE - Number of bytes, and opposite of the previous setting. Any PNG image larger than this size will not be optimized. Set to 0 to disable.

EWWW_IMAGE_OPTIMIZER_LOSSY_SKIP_FULL - Excludes full-size (original) images from lossy compression.

EWWW_IMAGE_OPTIMIZER_METADATA_SKIP_FULL - Excludes full-size images from metadata removal.

EWWW_IMAGE_OPTIMIZER_SKIP_BUNDLE - Tells the plugin not to install the bundled optimization utilities and use system-level binaries instead. For example, if you installed jpegtran, optipng, and gifsicle via yum or apt, you may wish to use those versions instead of the ones included with EWWW IO. I really don't recommend it, but you can if you want to.

Above, I showed you how to define a setting that is numeric, but several of these are simply on/off type settings. We call these "boolean" values, and you can set them like so:


Like I said before, any option that is an on/off toggle, or is numeric can be configured the same way. To find out the name of the option, right-click on it in your browser, and choose Inspect. There you will see the name/id attributes. Simply convert them to uppercase, and set them however you wish in wp-config.php.

Happy Optimizing!

Still need help? Contact Us Contact Us