PHPackages                             raffaelj/cockpit-imageresize - 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. raffaelj/cockpit-imageresize

ActiveCockpit-module[Image &amp; Media](/categories/media)

raffaelj/cockpit-imageresize
============================

Resize and optimize uploaded images automatically in Cockpit CMS

0.2.3(3y ago)8363[2 issues](https://github.com/raffaelj/cockpit_ImageResize/issues)[2 PRs](https://github.com/raffaelj/cockpit_ImageResize/pulls)1MITPHP

Since Aug 15Pushed 3y ago3 watchersCompare

[ Source](https://github.com/raffaelj/cockpit_ImageResize)[ Packagist](https://packagist.org/packages/raffaelj/cockpit-imageresize)[ Docs](https://github.com/raffaelj/cockpit_ImageResize)[ RSS](/packages/raffaelj-cockpit-imageresize/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (2)Versions (6)Used By (1)

ImageResize
===========

[](#imageresize)

**This addon is not compatible with Cockpit CMS v2.**

See also [Cockpit CMS v1 docs](https://v1.getcockpit.com/documentation), [Cockpit CMS v1 repo](https://github.com/agentejo/cockpit) and [Cockpit CMS v2 docs](https://getcockpit.com/documentation/), [Cockpit CMS v2 repo](https://github.com/Cockpit-HQ/Cockpit).

---

Addon for [Cockpit CMS](https://github.com/agentejo/cockpit/) to resize and optimize uploaded images automatically

Requirements, compatibility
---------------------------

[](#requirements-compatibility)

Since v0.2.0, ImageResize requires Cockpit v0.10.1 or above.

I rewrote a lot of the code to make use of the new `cockpit.asset.upload` event. It should now also be compatible with the cloud storage addon, but I wasn't able to test it, yet.

If you enable the `optimize` option, the \[ImageOptimizer addon\] is obsolute. Don't use both addons together.

Installation
------------

[](#installation)

Copy this repository into `/addons` and name it `ImageResize` or use the cli.

### via git

[](#via-git)

```
cd path/to/cockpit
git clone https://github.com/raffaelj/cockpit_ImageResize.git addons/ImageResize
```

### via cp cli

[](#via-cp-cli)

```
cd path/to/cockpit
./cp install/addon --name ImageResize --url https://github.com/raffaelj/cockpit_ImageResize/archive/master.zip
```

### via composer

[](#via-composer)

Make sure, that the path to cockpit addons is defined in your projects' `composer.json` file.

```
{
    "name": "my/cockpit-project",
    "extra": {
        "installer-paths": {
            "addons/{$name}": ["type:cockpit-module"]
        }
    }
}
```

```
cd path/to/cockpit-root
composer create-project --ignore-platform-reqs aheinze/cockpit .
composer config extra.installer-paths.addons/{\$name} "type:cockpit-module"

composer require --ignore-platform-reqs raffaelj/cockpit-imageresize
```

Usage
-----

[](#usage)

A copy of the original file is stored in `/uploads/full/filename.jpg`. The default file will be replaced with the resized file. From now on, you don't have to create thumbnails from 8MB sized files again, but you are still able to use the original file, if you want to.

If users upload very large images, it will take a while to process the files.

There is no option in the assets manager to choose the original file, but your api autput has two additional keys:

**original keys:**

```
"path": "/2019/07/02/filename.jpg",
"title": "DSC07504.JPG",
...

```

**extra keys:**

```
"sizes": {
    "full": {
        "path": "/full/filename.jpg",
        "width": 4912,
        "height": 3264,
        "size": 4390912
    }
},
"resized": true,

```

Options
-------

[](#options)

The GUI is outdated and doesn't provide all options.

`config/config.php`:

```
