PHPackages                             aspendigital/oc-resizer-plugin - 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. aspendigital/oc-resizer-plugin

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

aspendigital/oc-resizer-plugin
==============================

Smart image resizing and thumbnail generation for OctoberCMS

v1.2.0(5y ago)12164↓100%4[1 PRs](https://github.com/aspendigital/oc-resizer-plugin/pulls)MITPHP

Since Mar 26Pushed 3y ago4 watchersCompare

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

READMEChangelogDependenciesVersions (6)Used By (0)

Smart Image Resizer Plugin for OctoberCMS Build 420+
====================================================

[](#smart-image-resizer-plugin-for-octobercms-build-420)

This plugin allows you to offload image resizing from page rendering by either pushing image resize jobs onto a queue or by resizing on image load. This functionality is most useful on image-heavy sites where the images to be displayed will change over time and various sizes of the same image are used in your site templates.

For the best user experience, it's anticipated that wherever possible you will be pre-generating the image sizes you need, e.g. by triggering relevant page renders when image galleries change via the backend. The purpose of this plugin is to make that easier by avoiding page execution time limits and handling resizes in queue workers where higher memory limits might be appropriate.

If for some reason required image sizes were not pre-generated and don't exist at the time a site visitor accesses a page, the page can render and start displaying before the image resizes have been performed. Depending on server load and your configuration, there may still be a significant delay before your visitor can load all page images, but they should experience temporary slowness loading images rather than long waits for page loads or PHP execution time limit errors.

Usage
-----

[](#usage)

A `smart_resize` filter is available for use in your Twig templates. This filter is almost a drop-in replacement for the `getThumb` function provided by [OctoberCMS file attachments](http://octobercms.com/docs/database/attachments#viewing-attachments) with the addition of a `priority` parameter to specify queueing priority.

The full list of available parameters is `smart_resize(width, height, options, priority)`

ParameterDescription**width**integer: desired image width. 0 if height should be used as the sole constraint.**height**integer: desired image height. 0 if width should be used as the sole constraint.**options**(optional) string or array: if a string, it is used as the `mode` option. All `getThumb` options are the same, but this plugin adds some options. See the next table.**priority**(optional) string: the priority level to use for queuing (more below). By default takes the `defaultPriority` value set in the plugin config.Added options:

OptionDefaultDescription**upscale**false`getThumb` will automatically upscale images to match your desired dimensions, but this plugin will only do so if `upscale` is true or "exact" is the `mode`.**flatten**falseSet to true to flatten transparent images using the `background` option.**background**\[0,0,0\]Array of RGB values specifying a background color to use when flattening an image. Has no effect if `flatten` is false.### File attachment `getThumb` replacement

[](#file-attachment-getthumb-replacement)

```

```

becomes

```

```

### Direct paths

[](#direct-paths)

In addition to handling file attachment objects, you can also pass the filter an image path in your `media` or `uploads` storage. Consistent with paths saved by the `mediafinder` form widget, `media` paths should use the `media` folder as the root. Paths in `uploads` should be written relative to the project root.

As an example, considering a default directory structure:

```
-- storage
   `-- app
       `-- media
           `-- media_file.jpg
       `-- uploads
           `-- test_upload.jpg

```

your page could contain the following markup:

```

```

### Global function

[](#global-function)

A global `smartResize` function is defined for use in the back end (or wherever). This function's first parameter is the file attachment object or string path, followed by the same parameters as the Twig filter. Like the filter, it returns the URL to use for loading the resized image.

```
$resizedUrl = smartResize('/media/file.jpg', 300, 200);

```

Priority levels
---------------

[](#priority-levels)

By default, this plugin is set up with two priority levels which impact the way resize jobs are queued: `high` and `default`:

```
...
    'priorityLevels' => [
        /*
         * The key defines the priority level to use in the Twig filter,
         * e.g. {{ image || smart_resize(600, 400, 'auto', 'high) }}
         */
        'high' => [
            'isPriority' => true, // true to send to queue as soon as a batch is ready
            'queue'      => null, // The queue name to send jobs to, or null for the default
        ],
        'default' => [
            'isPriority' => false,
            'queue'      => null
        ]
    ],
...

```

As an example where priority levels can be useful, consider an image gallery displaying thumbnails on the page with a link to a larger generated image size. The thumbnails will be loaded automatically on page load, but the larger images may or may not be loaded by a site visitor. So we may choose to use markup similar to the following:

```
...
{% for image in gallery_images %}

{% endfor %}
...

```

Because `isPriority` is set for the `high` priority level, resize batches will be sent to the queue as soon as they're ready, and when the page has finished rendering, any remaining resizes at the `high` priority level will be queued before sending the rest.

That works great if one page needing image generation is rendered at a time, but if there's a possibility of other pages queuing image resizes concurrently, you may want to set up queueing with priorities as explained in the [queue documentation](http://octobercms.com/docs/services/queues). With our example markup above, assigning each priority level to a different queue via the `queue` setting would allow prioritizing thumbnail generation for a gallery page ahead of the larger images being resized for another gallery page queued earlier.

License
-------

[](#license)

[MIT License](LICENSE.md)

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 86.7% 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 ~204 days

Total

4

Last Release

1987d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/520306d0cfae0a55106325622aaf3b44b9d0dc50b13b7baf2473e007df127880?d=identicon)[jimcottrell](/maintainers/jimcottrell)

---

Top Contributors

[![jimcottrell](https://avatars.githubusercontent.com/u/1483197?v=4)](https://github.com/jimcottrell "jimcottrell (13 commits)")[![linkapiotr](https://avatars.githubusercontent.com/u/35471762?v=4)](https://github.com/linkapiotr "linkapiotr (1 commits)")[![petehalverson](https://avatars.githubusercontent.com/u/911099?v=4)](https://github.com/petehalverson "petehalverson (1 commits)")

### Embed Badge

![Health badge](/badges/aspendigital-oc-resizer-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/aspendigital-oc-resizer-plugin/health.svg)](https://phpackages.com/packages/aspendigital-oc-resizer-plugin)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k22](/packages/bkwld-croppa)[marc1706/fast-image-size

fast-image-size is a PHP library that does almost everything PHP's getimagesize() does but without the large overhead of downloading the complete file.

959.4M20](/packages/marc1706-fast-image-size)[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

495225.1k1](/packages/char0n-ffmpeg-php)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)

PHPackages © 2026

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