As you may have noticed, EWWW IO has a lot of ways that you can override the default behavior. Additionally, it is 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:
define( 'EWWW_IMAGE_OPTIMIZER_DELAY', 5 );
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 was removed from the settings page.
Important: For all overrides, make sure that you insert the option above where it says to stop editing. There will always be a line in your wp-config.php that says something like "That's all, stop editing!". Adding anything below that line will not have any effect. Also, make sure you do not use quotes around boolean (true/false) and numerical values or this will turn them into strings, like 'something', 'false', or '8'.
This first list includes only those settings that are hidden from the settings page:
EWWW_IMAGE_OPTIMIZER_NOAUTO - (true/false) Set to true 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_DISABLE_EDITOR - (true/false) EWWW IO is the only plugin to feature automatic optimization for every single image created by the built-in image editing functions. In rare cases, this can cause issues, set this to true to disable the image editor integration.
EWWW_IMAGE_OPTIMIZER_DISABLE_AUTOROTATE - (true/false) The plugin automatically rotates images that have an orientation flag set in their metadata to prevent your images from going sideways, literally. Set to true to suppress this auto-correction.
EWWW_IMAGE_OPTIMIZER_DISABLE_AUTOCONVERT - (true/false) The plugin automatically checks newly uploaded PNG files to see if they should have been saved as JPG instead, and will convert them as necessary. This happens very early in the process, so it's quite safe, but if you have some reason to preserve large PNG images, by all means, set this to true.
EWWW_IMAGE_OPTIMIZER_DEFER_S3 - (true/false) Prevents the WP Offload S3 plugin from uploading images to S3 until after optimization is complete. This can cause the appearance of missing images temporarily, so use with caution.
EWWW_IMAGE_OPTIMIZER_OPTIPNG_LEVEL - (1-4) Optipng runs a certain number of "trials" to determine the best compression parameters for an image. The default level is 2 (8 trials), you can decrease that to 1 (1 trial) if large PNG files are taking too long, or you can increase it to 3 (16 trials) or 4 (24 trials) to ensure maximum compression.
EWWW_IMAGE_OPTIMIZER_PNGOUT_LEVEL - (3-0) The default here is again 2, and it has a reverse scale: 3 is lowest compression, 0 is the highest. Level 3 doesn't do much more than what Optipng has already done, so if you're going to use PNGOUT, it's recommended to use level 2 or better.
EWWW_IMAGE_OPTIMIZER_DISABLE_PNGOUT - (true/false) 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 automatically via the Plugin Status section (after it is enabled) or manually in the wp-content/ewww/ folder. If the latest version doesn't work, you can try older versions manually.
EWWW_IMAGE_OPTIMIZER_SKIP_SIZE - (0 or greater) 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 - (0 or greater) 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 - (true/false) Excludes full-size (original) images from lossy (Premium) compression. Lossless compression will be applied instead. Also prevents PNG to JPG conversion, since that is a lossy optimization.
EWWW_IMAGE_OPTIMIZER_METADATA_SKIP_FULL - (true/false) Excludes full-size (original) images from metadata removal.
EWWW_IMAGE_OPTIMIZER_SKIP_BUNDLE - (true/false) 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.
EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP - (true/false) By default, PNG images are converted to WebP in lossless mode, unless you are using Premium (lossy) compression for the PNG format already. If you want to enforce lossy PNG to WebP conversion, set this one to true.
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 (true/false) values, and you can set them like so:
define( 'EWWW_IMAGE_OPTIMIZER_NOAUTO', true );
Like I said before, any option that is an on/off toggle, or is numeric can be configured the same way.
To that end, this second list (work in progress) is the current options that are displayed in the UI which can be configured in wp-config.php:
EWWW_IMAGE_OPTIMIZER_METADATA_REMOVE - (true/false) If set to true, it will remove metadata. Set it to false to preserve metadata.
EWWW_IMAGE_OPTIMIZER_JPG_LEVEL - (0, 10, 20, 30, 40) A zero is no compression, level 10 is Pixel Perfect (lossless), level 20 is Pixel Perfect Plus (lossless via API), level 30 is Premium (lossy), and level 40 is Premium Plus (maximum lossy).
EWWW_IMAGE_OPTIMIZER_PNG_LEVEL - (0, 10, 20, 40, 50) A zero is no compression, level 10 is Pixel Perfect (lossless), level 20 is Pixel Perfect Plus (lossless via API), level 40 is Premium (lossy), and level 50 is Premium Plus (maximum lossy). Yes, level 30 is missing, because it is an old setting that has become obsolete.
EWWW_IMAGE_OPTIMIZER_GIF_LEVEL - (0 or 10) A zero is no compression, and level 10 is Pixel Perfect (lossless).
EWWW_IMAGE_OPTIMIZER_PDF_LEVEL - (0, 10, 20) A zero is no compression, level 10 is Pixel Perfect (lossless), level 20 is high quality compression. Level 20 for PDFs doesn't get the premium designation, as it's just a raw image down-sampler, which can have issues if any images have text within them.
EWWW_IMAGE_OPTIMIZER_BACKUP_FILES - (true/false) This enables backups via the compression API, stored for 30 days.
EWWW_IMAGE_OPTIMIZER_JPG_QUALITY - (0-100) Overrides the default WordPress quality of 82. Does not generally affect EWWW IO compression, but is applied to any resizing, editing, and conversion functions.
EWWW_IMAGE_OPTIMIZER_PARALLEL_OPTIMIZATION - (true/false) Depends on background optimization, allows the plugin to compress thumbnail/resize images in parallel after a new image upload.
EWWW_IMAGE_OPTIMIZER_AUTO - (true/false) Not to be confused with the "noauto" setting, this one enables/disables Scheduled Optimization. While it IS available in the settings, it can be helpful to disable this on staging/development sites so that it only runs in production.
EWWW_IMAGE_OPTIMIZER_INCLUDE_MEDIA_PATHS - (true/false) With this enabled, bulk processed (including scheduled optimization) will scan the latest two months of the uploads folder for any images that might not show up during regular scanning. In particular, scheduled optimization does not normally include ANY media library images unless you use this option or the Folders to Optimize setting.
EWWW_IMAGE_OPTIMIZER_ENABLE_HELP - (true/false) Enables the embedded help links and direct access to our contact form, all right within your WordPress dashboard.
EWWW_IMAGE_OPTIMIZER_ALLOW_TRACKING - (true/false) Enables anonymous usage tracking.
EWWW_IMAGE_OPTIMIZER_RESIZE_DETECTION - (true/false) Helps you detect over-sized images by putting a black/blue dashed border around any such images.
EWWW_IMAGE_OPTIMIZER_MAXMEDIAWIDTH - (0 or greater) Scale any images to fit within the specified number of pixels.
EWWW_IMAGE_OPTIMIZER_MAXMEDIAHEIGHT - (0 or greater) Scale any images to fit within the specified number of pixels.
EWWW_IMAGE_OPTIMIZER_RESIZE_EXISTING - (true/false) Allows resizing of images via the bulk optimizer. Otherwise, only new images are resized.
EWWW_IMAGE_OPTIMIZER_DISABLE_CONVERT_LINKS - (true/false) The Media Library, when in list mode, will normally have links to attempt various conversion options (like PNG to JPG). Set this to true if you want them hidden.
EWWW_IMAGE_OPTIMIZER_DELETE_ORIGINALS - (true/false) First, this option has no bearing on regular image optimization, since optimization replaces the originals with the newly compressed images. This option tells the plugin to delete the original if an image is converted between formats, like PNG to JPG, or GIF to PNG. This can cause broken links, but keeping the originals will use extra disk space.
EWWW_IMAGE_OPTIMIZER_JPG_TO_PNG - (true/false) Checks JPG images if they should be in the PNG format instead. This is a bad idea, seriously, since JPG to PNG should really only be attempted when you suspect an image is a good candidate for JPG to PNG. In other words, it should be used selectively, not en masse.
EWWW_IMAGE_OPTIMIZER_PNG_TO_JPG - (true/false) Checks PNG images if they should be in the JPG format instead. This is more common than the above, and can certainly be enabled globally with this override.
EWWW_IMAGE_OPTIMIZER_GIF_TO_PNG - (true/false) Checks GIF images if they should be in the PNG format instead. This is the most common of the conversion operations (if you upload GIF images at all). Unless a GIF is animated, it probably will be smaller as a PNG.
EWWW_IMAGE_OPTIMIZER_WEBP - (true/false) Checks every PNG and JPG image to see if the WebP format is smaller. The original image is always maintained for non-WebP browsers, and you'll need some sort of rewriting method to serve the new WebP images to supported browsers.
EWWW_IMAGE_OPTIMIZER_WEBP_FORCE - (true/false) Produce a WebP image for every PNG and JPG image, regardless of the file size. Typically, one would use this if your images are not served from the local server, but from a CDN or something of that nature.
EWWW_IMAGE_OPTIMIZER_WEBP_FOR_CDN - (true/false) Also known as JS (Alternative) WebP Rewriting, this is typically used when a CDN or proxy server is between your server and your visitors.