filter · Image filters
Resize images for mobile (resize_mobile_images)
- Category:
- Image
- CoreFilters:
- No
- OptimizeForBandwidth:
- No
- Risk:
- Test first
resize_mobile_images serves smaller images to mobile devices based on the User-Agent header. Enabling it also enables inline_preview_images, which it depends on.
When to use it
- Not in CoreFilters: it runs only when you enable it by name.
- Risk rating on these docs: Test first.
Risks
-
Inlining increases HTML size. Inlined images are not cached separately by the browser. Set
ImageInlineMaxBytesconservatively. -
resize_mobile_imagesrelies on User-Agent detection. Incorrect UA classification can serve wrong-sized images. It also pulls ininline_preview_images, so expect that filter’s placeholder-then-swap behavior when enabling it.
Configuration
Enable it in the module configuration, at server, virtual-host or location scope:
Apache
ModPagespeedEnableFilters resize_mobile_imagesnginx
pagespeed EnableFilters resize_mobile_images;IIS (pagespeed.config)
pagespeed EnableFilters resize_mobile_images| Parameter | Default | Description |
|---|---|---|
ImageInlineMaxBytes | 3072 | Maximum image size in bytes to inline as a data: URI |
Scoping, ForbidFilters and the thresholds filters read:
Choosing filters
.
Live example
Serves smaller low-quality placeholders to mobile browsers, then the full image.
This filter changes how the page is structured or delivered, not its size, so the example shows a source diff rather than a byte or request reduction.
Frequently asked questions
- What does the resize_mobile_images filter do?
resize_mobile_imagesserves smaller images to mobile devices based on the User-Agent header. Enabling it also enablesinline_preview_images, which it depends on.- Is resize_mobile_images enabled by default?
- No.
resize_mobile_imagesis not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name withEnableFilters. - How do I enable resize_mobile_images on Apache and nginx?
- Add
ModPagespeedEnableFilters resize_mobile_imageson Apache orpagespeed EnableFilters resize_mobile_images;on nginx. On IIS, addpagespeed EnableFilters resize_mobile_imagesto pagespeed.config.
Related filters
- dedup_inlined_images — Deduplicate inlined images
- inline_images — Inline images
- inline_preview_images — Inline preview images
- convert_gif_to_png — Convert GIF to PNG
- convert_jpeg_to_avif — Convert JPEG to AVIF
- convert_jpeg_to_progressive — Progressive JPEG
- convert_jpeg_to_webp — Convert JPEG to WebP
- convert_png_to_jpeg — Convert PNG to JPEG
This page is drawn from the resize_mobile_images entry on Image filters. Every filter in one table: PageSpeed filters.