Skip to main content

filter · Image filters

Resize to rendered dimensions (resize_rendered_image_dimensions)

Category:
Image
CoreFilters:
No
OptimizeForBandwidth:
No
Risk:
Test first

resize_rendered_image_dimensions injects JavaScript that reports each image’s actual rendered dimensions on the client. On subsequent requests, mod_pagespeed resizes to the rendered size. Requires two page loads to take effect.

When to use it

  • Not in CoreFilters: it runs only when you enable it by name.
  • Risk rating on these docs: Test first.

Risks

  • resize_rendered_image_dimensions injects JavaScript and requires two page loads. The first load serves the original image.

Configuration

Enable it in the module configuration, at server, virtual-host or location scope:

Apache

ModPagespeedEnableFilters resize_rendered_image_dimensions

nginx

pagespeed EnableFilters resize_rendered_image_dimensions;

IIS (pagespeed.config)

pagespeed EnableFilters resize_rendered_image_dimensions
ParameterDefaultDescription
ImageLimitResizeAreaPercent100Only resize if the result is this percentage of the original area or less

On the worker

The worker runs its own pipeline, configured by flags. Its equivalent of this filter is the image pipeline transform. Always-on baseline under pagespeed on;; there is no per-transform off switch.

Scoping, ForbidFilters and the thresholds filters read: Choosing filters .

Live example

Resizes an image to the dimensions it is actually rendered at on the page.

mod_pagespeed applies this only after a real browser loads the page and reports back, so the example shows it live rather than as a captured diff.

See the before and after, with the source diff →

Frequently asked questions

What does the resize_rendered_image_dimensions filter do?
resize_rendered_image_dimensions injects JavaScript that reports each image's actual rendered dimensions on the client. On subsequent requests, mod_pagespeed resizes to the rendered size. Requires two page loads to take effect.
Is resize_rendered_image_dimensions enabled by default?
No. resize_rendered_image_dimensions is not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name with EnableFilters.
How do I enable resize_rendered_image_dimensions on Apache and nginx?
Add ModPagespeedEnableFilters resize_rendered_image_dimensions on Apache or pagespeed EnableFilters resize_rendered_image_dimensions; on nginx. On IIS, add pagespeed EnableFilters resize_rendered_image_dimensions to pagespeed.config.

This page is drawn from the resize_rendered_image_dimensions entry on Image filters. Every filter in one table: PageSpeed filters.

Search