WordPress Plugin

Easy to use, well tested and feature-rich WordPress plugin for image compression/optimization.

Three different compression levels

Supports the three different compression levels: ultra, intelligent and lossless.

Backup & Restore options

Options to automatically backup image, restore if backup available or delete specific backups

Thumbnail optimization support

WordPress creates thumbnails for each full size image. You can now choose which thumbnail versions to be optimized!

WP Offload Media / WP Offload S3 support

MegaOptim integrate with WP Offload Media plugin and makes possible optimizing images in your storage bucket with amazon, google storage, digital ocean spaces and much more.

WebP support

WebP is newer image encoding format that reduces the image size up to 20% and is recommended to use nowadays. It can be enabled from the settings.

Retina support

Seamlessly integrates with WP Retina 2x and auto optimizes your retina images and thumbnails.

WP-CLI Support

If you prefer to work from the command line we have great news for you. The plugin provides few WP CLI commands that will help you optimize your images. Read more here.

Compatibility with other plugins

Integrates with different gallery plugins(NextGen, MediaPress, Envira, Foo Gallery, Robo Gallery), CloudFlare, WP Offload S3, WP Stateless, etc.

Built with love for developers

The plugin offers different developer hooks as follows:
(Note: This page is constantly updated to match the last version).


/**
 * Fired after attachment is optimized and before the process is finished.
 *
 * @param  MGO_MediaAttachment|MGO_LocalFileAttachment|MGO_NextGenAttachment $attachment_object
 * @param  array $request_params - The request parameters
 */
function megaoptim_before_optimization_238182812($attachment_object, $request_params) {
    // Do something
}
add_action('megaoptim_before_optimization', 'megaoptim_before_optimization_238182812', 15, 2);

/**
 * Fired after regular attachment is optimized
 *
 * @param  MGO_MediaAttachment|MGO_LocalFileAttachment|MGO_NextGenAttachment $attachment_object
 * @param  string $resource The url or the local path of the resource (If the site is local, the $resource will be local path, if the site is public the $resource will be url.)
 * @param  \MegaOptim\Responses\Response $response
 * @param  array $request_params - The request parameters
 * @param  string $size
 */
function megaoptim_attachment_optimized_238182812($attachment_object, $resource, $response, $request_params, $size) {
    // Do something
}
add_action('megaoptim_attachment_optimized', 'megaoptim_attachment_optimized_238182812', 15, 5);

/**
 * Fired after retina attachment is optimized.
 *
 * @param  MGO_MediaAttachment|MGO_LocalFileAttachment|MGO_NextGenAttachment $attachment_object
 * @param  string $resource The url or the local path of the resource (If the site is local, the $resource will be local path, if the site is public the $resource will be url.)
 * @param  \MegaOptim\Responses\Response $response
 * @param  array $request_params - The request parameters
 * @param  string $size
 */
function megaoptim_retina_attachment_optimized_238182812($attachment_object, $resource, $response, $request_params, $size) {
    // Do something
}
add_action('megaoptim_retina_attachment_optimized', 'megaoptim_retina_attachment_optimized_238182812', 15, 5);

/**
 * Fired after attachment is optimized and before the process is finished.
 *
 * @param  MGO_MediaAttachment $attachment_object
 * @param  array $request_params - The request parameters
 */
function megaoptim_before_finish_238182812($attachment_object, $request_params) {
    // Do something
}
add_action('megaoptim_before_finish', 'megaoptim_before_finish_238182812', 15, 2);


/**
 * Fired after the attachment is restored from backup.
 * MGO_MediaAttachment|MGO_LocalFileAttachment|MGO_NextGenAttachment $attachment_object
 */
function megaoptim_after_restore_attachment_283823842($attachment_object) {
    // Do something
}
add_action('megaoptim_after_restore_attachment', 'megaoptim_after_restore_attachment_283823842', 15, 1);