Back to Guides

Vyso Guides

WordPress image compression: a practical guide

Updated October 6, 2026
WordPressImage compression

WordPress image compression reduces the bytes visitors download. For new images, resize and compress a copy before uploading it, then check the smaller versions WordPress generates. For an existing Media Library, use an optimizer that processes the files your pages actually serve. Changing a quality setting alone does not rewrite images already on disk.

Start with one photo and one page. Compare the downloaded file and its visible detail before applying the same settings to the whole library. For responsive markup, loading order, and the wider performance workflow, see the WordPress image optimization guide.

File size, image dimensions, and compression

File size is measured in bytes, usually displayed as KB or MB. Image dimensions are the width and height in pixels. Reducing dimensions removes pixels; compression changes how the remaining image data is stored. Both can reduce a download, but they solve different problems.

Suppose a photograph is 4000 pixels wide and the largest place you display it is an 800-pixel article column. An export around 1600 pixels wide can serve that column on a 2× display. Keep more resolution if readers need a larger gallery or zoom view. This is a layout example, not a universal WordPress upload limit.

Lossless compression preserves the decoded pixel data. Lossy compression discards some information and can introduce artifacts. JPEG is lossy; PNG uses lossless compression; WebP supports both. For photographs, lossy output is often suitable. For screenshots and diagrams, inspect small text and hard edges carefully. MDN's image format guide explains the differences.

A quality value is an encoder setting, not a percentage reduction in file size. Quality 80 does not mean a file becomes 80% smaller, and quality 80 in one format is not equivalent to quality 80 in another. Compare the exported bytes and visible result.

What WordPress compresses automatically

WordPress creates smaller or cropped versions of uploaded images for registered image sizes. Themes and plugins can register additional sizes. These generated files are the ones used for many article images, cards, and shop thumbnails.

The default JPEG quality in the WordPress image editor is 82. A theme, plugin, or custom filter can change it. That setting applies when WordPress encodes an image; uploading a JPEG does not mean every copy of that attachment, including the uploaded source, is recompressed to the same quality.

In the standard processing path, an image exceeding the default threshold of 2560 pixels in either dimension can receive a -scaled version used as its main, or full, image. The original is retained. The threshold can be changed or disabled, and successful scaling depends on image processing support. See WordPress's sub-size generation code.

WordPress 7.1 also introduces browser processing for supported block-editor uploads. Compression and thumbnail generation can happen in the editor's browser. Unsupported browsers or runtime conditions fall back to server processing. Test the upload path your editors use; a successful block-editor upload does not establish that a server-side bulk job supports the same formats.

Native processing provides useful image variants. It does not provide a dashboard command that compresses your entire existing library to a chosen file-size target.

How to compress images in WordPress

Prepare a smaller file before uploading

For a small site, preparing each export is a workable way to compress images for a website without installing an optimizer. Keep the source separately so future exports can start from it.

  1. Measure the largest intended display width. Include a gallery or product zoom if the same image is used there. Resize a copy to the resolution that use needs.

  2. Open the copy in an image editor or Squoosh, which compresses images locally in your browser. Choose an output format appropriate to the image and your site's processing support.

  3. For a photograph, try a lossy export and adjust quality while watching the preview. Check faces, gradients, foliage, and product detail. For screenshots, compare lossless output if lossy compression blurs text.

  4. Download the result and record its dimensions and file size. Judge it at the intended display size, then inspect detailed areas at 100% zoom. If the result is too soft, increase quality or revisit the dimensions.

  5. Upload it through Media → Add New or the post editor. Insert an image size suited to the layout and check the published page. WordPress may encode smaller derivatives again, so the pre-upload preview is only the first quality check.

There is no file-size target that suits every image. A small card, a detailed tutorial screenshot, and a product zoom have different needs. Set a budget for each use and keep the smallest export that still communicates the necessary detail.

Reduce dimensions in the Media Library

For a single uploaded image, open Media → Library, select the attachment, and choose Edit Image. Under Scale Image, enter a smaller dimension while preserving the aspect ratio, apply the scale, and save the edit. The exact arrangement depends on the administration screen and WordPress version.

The native image editor scales images down and can restore the uploaded original. Previously edited copies are not automatically removed when you restore it. Scaling is useful for excessive resolution; it is not a bulk compression tool or a dashboard control for JPEG quality.

After editing, inspect the page that uses the attachment. A builder or manually pasted URL can still refer to another file. Reducing the displayed width with CSS alone does not guarantee a smaller download.

Use a WordPress image compressor for repeated uploads

An image compression plugin can automate the work when several people upload media or an existing library needs processing. Select it by the files it handles and the way it changes your site.

ShortPixel Image Optimizer, for example, documents automatic uploads, bulk processing, lossy and lossless modes, and optional original-image backups. It uses a cloud service and requires an API key. Its interface includes Settings → ShortPixel and Media → Bulk ShortPixel.

Smush also documents compression of uploads and bulk processing. Its WebP/AVIF delivery and CDN features are identified as Pro features. Check the currently available features for your chosen edition before planning a conversion workflow.

After installing your chosen plugin, enable backups if available, select a compression mode, and process a small sample. Open a page that uses those images before enabling automatic processing or starting a bulk job. Include a photograph, a screenshot, and a transparent graphic if your site uses them.

Some tools compress files stored in WordPress; others transform images through a delivery service. A smaller CDN response does not necessarily reduce the disk space used by your Media Library. Check where processing happens, whether originals leave your server, and which generated sizes are included.

WordPress image compression settings

Media settings control dimensions

Settings → Media contains dimensions for thumbnail, medium, and large images, plus the thumbnail crop option. These are image-size settings. They do not provide a site-wide compression-quality slider.

Choose dimensions that your layout can use. A theme or shop plugin may define other sizes elsewhere. Changing these settings affects later image generation; existing derivatives need separate regeneration if you want them rebuilt.

Change JPEG encoding quality with a filter

Developers can change generated JPEG quality through the wp_editor_set_quality filter. The example below sets JPEG output to 78 and leaves other formats unchanged. The number is a trial setting, not a recommendation for every site.

add_filter(
    'wp_editor_set_quality',
    function ( $quality, $mime_type ) {
        if ( 'image/jpeg' === $mime_type ) {
            return 78;
        }

        return $quality;
    },
    10,
    2
);

Place this in a site-specific plugin, an existing snippet manager, or a child theme's functions.php. Test it on staging first. Editing the parent theme directly makes the setting vulnerable to a theme update.

The filter changes default quality when the image editor applies it. A later legacy jpeg_quality filter can override JPEG quality, and an explicit quality argument can take priority. An optimizer's independent encoder may use its own setting.

Upload a new test image and compare a generated JPEG. Existing files remain unchanged until processed again. Setting quality to 100 does not restore detail already lost through compression, and this JPEG-only snippet does not optimize PNG images.

Configure the optimizer around the files you serve

Labels vary by plugin, but these decisions determine what actually gets compressed:

  • Compression mode. Start with lossless when exact pixel reproduction matters. For photographs, test lossy output against the visible detail you need to preserve.

  • Processing scope. Include the generated sizes your pages request. Compressing the uploaded original alone can leave the existing thumbnails unchanged.

  • Originals and backups. Decide whether to optimize the main file, retain a source copy, and keep a restorable backup. Backups and extra format variants also need storage.

  • Format conversion and delivery. Creating WebP or AVIF files and making pages serve them are separate jobs. Check both before concluding that conversion worked.

  • Maximum dimensions and metadata. Set a resize limit that preserves your largest intended use. Before stripping embedded metadata, check whether copyright, attribution, or other information needs to remain with the file.

Use one defined compression workflow. If a second plugin re-encodes the same JPEG, visual damage can accumulate and it becomes harder to identify which setting produced the result.

When to use WebP or AVIF

WordPress supports WebP uploads from version 5.8 and AVIF from version 6.5. For server processing, the active image library needs support for the format. Check Tools → Site Health → Info → Media Handling. The browser-processing path described above has different requirements.

Compare formats using the same image dimensions and acceptable visible quality. A modern format can reduce bytes, but the result depends on the source and encoder. Keep JPEG or PNG where it gives a better result or a required compatibility fallback.

WordPress support for a format does not mean every uploaded JPEG is automatically converted to it. Conversion needs configuration, such as the native image_editor_output_format filter or a plugin. Existing files also need a separate processing pass. Renaming photo.jpg to photo.webp does not convert its contents.

Inspect the actual response after enabling conversion. A CDN can serve WebP at a URL ending in .jpg, while an unused WebP file on your server saves visitors no bytes.

Compress images already uploaded to WordPress

Begin with attachments used on important pages. Back up the uploads and database, then process a small batch before changing the whole library. Check old posts, galleries, product images, and directly embedded URLs after the trial.

Bulk compression and thumbnail regeneration are different operations. An optimizer compresses the files in its selected scope. Regeneration recreates registered sizes, using the applicable image-processing settings. If you change JPEG quality and want existing derivatives to use it, those derivatives must be re-encoded.

With WP-CLI installed, run the following from the WordPress installation directory for a sample attachment. Here, 123 is an example attachment ID; use the ID of an image on your site.

wp media regenerate 123 --skip-delete

The regenerate command rebuilds attachment thumbnails. --skip-delete retains old thumbnail files that might still be referenced elsewhere. It does not preserve overwritten bytes at the same filename or replace a backup. Omitting --only-missing matters: that option skips existing sizes, so it cannot apply a new quality setting to them.

Regeneration runs on the server. Confirm server support before rebuilding WebP or AVIF attachments, even if browser uploads work. Generate the required sizes before a separate optimization pass, unless your optimizer explicitly handles regenerated files.

For a large library, work in manageable batches and review errors before continuing. When replacing a file manually, use a workflow that preserves the attachment's references. Deleting it and uploading a new attachment can leave older pages pointing to the removed file.

Check that visitors download smaller images

WordPress's responsive image markup can list several candidates in srcset and describe the display width through sizes. The browser selects a candidate. Compressing a file that the page never requests does not reduce that page's download.

Open the published page while logged out and set the mobile viewport before reloading. In Chrome DevTools, open Network, check Disable cache, filter image requests, and reload. Compare the requested URL, transferred bytes, and response Content-Type. The Network panel documentation explains these controls. Disabling the browser cache does not purge a WordPress or CDN cache; clear affected variants through the system that manages them.

For responsive images, inspect currentSrc to identify the selected file. Check its pixel dimensions against the display width and screen density. Repeat the comparison at desktop width with a fresh reload and the same test conditions.

Review visible quality separately from the byte count. Check product labels, small text, transparent edges, gradients, and the largest view readers can open. An attractive small preview can hide damage in a product zoom.

If a photo becomes blurry, check whether its dimensions are too small before raising compression quality. If its downloaded file is still large, check whether the page requests the original, a builder's background image, or an unprocessed derivative. If a conversion is not visible, check delivery configuration and caches.

Smaller files can shorten image downloads, but faster rendering also depends on when the request starts and when the page can display the result. For an image that is the Largest Contentful Paint element, compression alone does not fix late discovery or lazy loading. web.dev's LCP guidance separates these delays. Use the linked WordPress optimization guide for the broader loading workflow, and keep compression checks focused on the actual bytes and detail delivered.

Keep going

Make the media library less work.

See how Vyso brings search, enrichment, cleanup, and delivery into one product.

Start free