[files-module] I need to change image size on upload.

vargvinter - 2 weeks ago

Hello,

How can I hook my implementation to resize images without messing in core? I found that I can put my code into FileUploader file but as I wrote I don't want to mess in core.

Answer

ryanthompson - 2 weeks ago

Try binding your own FileUploader class to the core one. Otherwise I can write a hook cause I don't think one technically exists right now.

ryanthompson - 2 weeks ago

Try binding your own FileUploader class to the core one. Otherwise I can write a hook cause I don't think one technically exists right now.

vargvinter - 2 weeks ago

Thanks. Binding works. Now I have to implement my logic.

Some example for others:

config/streams.php

    'singletons' => [
        \Anomaly\FilesModule\File\FileUploader::class => \App\Providers\Abc::class
    ],

Custom class:

<?php

namespace App\Providers;

use Anomaly\FilesModule\File\FileUploader;

class Abc extends FileUploader
{

}

ryanthompson - 2 weeks ago

@vargvinter perfect - soon this will be baked into the module. Supporting different types of logic on upload. But this is a great way to do it for the time being.