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!

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.

Supports many other plugins

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

Developer hooks

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);