PHPackages                             generoi/wp-image-resizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. generoi/wp-image-resizer

ActiveWordpress-plugin[Image &amp; Media](/categories/media)

generoi/wp-image-resizer
========================

A plugin which provides dynamic image sizes through a CDN

v1.5.1(9mo ago)315.1k↓20.5%[1 PRs](https://github.com/generoi/wp-image-resizer/pulls)MITPHPPHP &gt;=7.0.0

Since Jul 25Pushed 9mo ago3 watchersCompare

[ Source](https://github.com/generoi/wp-image-resizer)[ Packagist](https://packagist.org/packages/generoi/wp-image-resizer)[ Docs](https://github.com/generoi/wp-image-resizer)[ RSS](/packages/generoi-wp-image-resizer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (6)Versions (10)Used By (0)

wp-image-resizer
================

[](#wp-image-resizer)

> A plugin which provides dynamic image sizes through a CDN

Requirements
------------

[](#requirements)

A resizer service, this plugin currently supports:

- A cloudflare CDN zone with image resizing enabled.
- KeyCDN with pull zone configured
- Fastly with image optimzer enabled

Note that you'll need to manage the `loading` attribute yourself. Only tags with `loading="lazy"` will get rewritten to use `lozad.js`. You should ensure that the LCP blocks have `loading="eager"` or no `loading` attribute at all.

`IMAGERESIZER_ZONE` environment variable is required.

### Environment variables

[](#environment-variables)

```
IMAGERESIZER_ZONE='https://myapp.com/cdn-cgi/image/'
IMAGERESIZER_DISABLED=false

```

Features
--------

[](#features)

- Use [lozad.js](https://github.com/ApoorvSaxena/lozad.js/) to lazyload images, iframes and videos
- Support for `sizes="auto"` through `data-sizes="auto"`
- Preload first blocks image
- Rewrite image URLs to use Cloudflare CDN
- Replace all WP `srcset` with our Cloudflare Image Resizing URLs

API
---

[](#api)

See [Cloudflare docs](https://developers.cloudflare.com/images/image-resizing/url-format/#options), [KeyCDN docs](https://www.keycdn.com/support/image-processing) or [Fastly docs](https://developer.fastly.com/reference/io/) for transformation options.

### Pass custom options

[](#pass-custom-options)

You can pass custom options to the resizer when using `wp_get_attachment_image` by setting `data-resizer-args` which supportes [`wp_parse_args`](https://developer.wordpress.org/reference/functions/wp_parse_args/) type strings.

```
wp_get_attachment_image($profileImage, 'full', false, [
  'data-resizer-args' => 'crop=1:1&quality=50',
  'sizes' => '(min-width: 40em) 48px, (min-width: 68.75em) 56px, (min-width: 87.5em) 64px, 40px'
])
```

### Generate src and srcset from URL

[](#generate-src-and-srcset-from-url)

```
use GeneroWP\ImageResizer\Image;

$image = new Image($url, [
    'blur' => 50,
]);

return sprintf(
    '',
    $image->src(),
    $image->srcset(),
    '100vw'
);
```

### Generate src and srcset from attachment

[](#generate-src-and-srcset-from-attachment)

```
use GeneroWP\ImageResizer\Image;

$image = Image::fromAttachment($bannerImageId, 'full', [
    'fit' => 'cover',
    'height' => 350 * 2,
]);

return sprintf(
    '',
    $image->src(),
    $image->srcset(),
    '100vw'
);
```

### Add a preload link tag to head

[](#add-a-preload-link-tag-to-head)

```
use GeneroWP\ImageResizer\Rewriters\Preload;

add_action('wp_head', function () {
    if (is_singular('recipe')) {
        $composer = new ContentRecipe();
        $featured = $composer->featuredImageHtml(get_post());
        echo Preload::buildLink($featured);
    }
}, 2);
```

### Filters

[](#filters)

```
// Alter rewriters
add_filter('wp-image-resizer/rewriters', function (array $rewriters) {
    $rewriters[] = MyCustomRewriter::class;
    return $rewriters;
});

// Alter resizer URLs
add_filter('wp-image-resizer/image/url', function (string $url) {
    if (defined('WP_ENV') && WP_ENV === 'development') {
        $url = str_replace('development-domain.ddev.site', 'production-domain.com', $url);
    }
    return $url;
});

// Alter blocks that should be considered for preloading
add_filter('wp-image-resizer/preload/blocks', function (array $blockTypes) {
    $blockTypes[] = 'my-theme/hero-banner';
    return $blockTypes;
});

// Alter if preload should stop iterating blocks
add_filter('wp-image-resizer/preload/should_stop', function (bool $stop, array $block, array $blocks) {
    if ($block['blockType'] === 'my-theme/breadcrumb') {
        return false;
    }
    return $stop;
}, 10, 3);

// Alter srcset breakpoints
add_filter('wp-image-resizer/config/breakpoints', function (array $breakpoints) {
    return [
        ...range(50, 500, 50),
        ...range(600, 2000, 100),
    ];
});

// Alter default resizing settings
add_filter('wp-image-resizer/config/default', function (array $breakpoints) {
    return [
        'quality' => 90
    ];
});
```

Development
-----------

[](#development)

Install dependencies

```
composer install
npm install

```

Run the tests

```
npm run test

```

Build assets

```
# Minified assets which are to be committed to git
npm run build:production

# Watch for changes and re-compile while developing the plugin
npm run start

```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance55

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~104 days

Recently: every ~153 days

Total

8

Last Release

298d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/302736?v=4)[oxyc](/maintainers/oxyc)[@oxyc](https://github.com/oxyc)

---

Top Contributors

[![oxyc](https://avatars.githubusercontent.com/u/302736?v=4)](https://github.com/oxyc "oxyc (51 commits)")

---

Tags

wordpress

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/generoi-wp-image-resizer/health.svg)

```
[![Health](https://phpackages.com/badges/generoi-wp-image-resizer/health.svg)](https://phpackages.com/packages/generoi-wp-image-resizer)
```

###  Alternatives

[wp-sync-db/wp-sync-db-media-files

WP Sync DB Media File Addon for WP Sync DB

535151.4k](/packages/wp-sync-db-wp-sync-db-media-files)[humanmade/gaussholder

Fast and lightweight image previews for WordPress

196119.7k](/packages/humanmade-gaussholder)[viper007bond/regenerate-thumbnails

Regenerate the thumbnails for one or more of your image uploads. Useful when changing their sizes or your theme.

14012.2k](/packages/viper007bond-regenerate-thumbnails)[typisttech/image-optimize-command

Easily optimize images using WP CLI

1722.0k](/packages/typisttech-image-optimize-command)[toinekamps/responsive-pics

Responsive Pics is a Wordpress tool for resizing images on the fly.

831.2k](/packages/toinekamps-responsive-pics)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
