---
title: "Bulk Optimize Images Ability: Compress WordPress Media Library Images"
url: https://nexterwp.com/docs/nexter-ability-bulk-optimize-images/
date: 2026-05-29
modified: 2026-05-29
author: "sandip patel"
description: "The nexter/bulk-optimize-images ability compresses images in your WordPress Media Library. Target specific attachments or process the next unoptimized batch automatically."
word_count: 349
---

# Bulk Optimize Images Ability: Compress WordPress Media Library Images

## Key Takeaways

- Nexter Bulk Optimize Images compresses images in the WordPress Media Library using configured Nexter Image Optimization settings.
- Each processed image returns a result indicating success, skipped, or failed, along with bytes saved after optimization.
- The default batch size for processing images is 5, and users can set a limit between 1 to 25 to avoid PHP execution timeouts.

The **nexter/bulk-optimize-images** ability compresses images in your WordPress Media Library using your configured Nexter Image Optimization settings. You can target specific attachment IDs or let it process the next batch of unoptimized images automatically. This has the same effect as clicking **Start Bulk Optimisation** on **Media > Bulk Images**. Keep batch sizes small to avoid PHP timeouts.

## Key Takeaways

This ability modifies image files on disk by compressing and replacing them with optimized versions.

Each processed image returns its own result: success, skipped, or failed, along with bytes saved.

If you omit attachment_ids, the ability processes the next unoptimized images automatically up to the limit value.

The default batch size is 5 images. Each image can take several seconds to process on the server.

The Image Optimization extension must be enabled in Nexter Extension before this ability can run.

## Required Setup

The Image Optimization extension must be enabled in Nexter Extension settings. Call **nexter/get-bulk-image-optimizer-status** first to confirm unoptimized images exist. Use **nexter/get-image-optimization** to review your current compression settings before running.

## Parameters

Both parameters are optional. If you omit both, the ability processes the next 5 unoptimized images from your Media Library.

**attachment_ids** (array of integers, optional) accepts specific Media Library attachment IDs to optimize. If omitted, the ability picks the next unoptimized images automatically.

**limit** (integer, optional) sets how many images to process when attachment_ids is omitted. Accepts 1 to 25. Defaults to 5. Keep this small to avoid PHP execution timeouts.

## What It Returns

The ability returns a result object for each processed image in the batch.

**status** for each image: success, skipped, or failed.

**bytes_saved** for each successfully optimized image.

Per-image skip reasons that mirror what the **Media > Bulk Images** dashboard shows.

## When to Use This Ability

Compress a specific set of newly uploaded images by passing their attachment IDs directly.

Process the backlog of unoptimized images in small batches to avoid PHP server timeouts.

Build an automation that checks the queue with **nexter/get-bulk-image-optimizer-status** and then compresses images in batches.

## Related Documentation

nexter/get-bulk-image-optimizer-status: Check the optimization queue and stats before running

nexter/restore-original-images: Roll back all optimized images to their originals

nexter/update-image-optimization: Configure compression format and quality settings