Hello I'm using backpack which uses elfinder as a file manager, and i want to achive te following:
when an image is uploaded I want to create 3 copies of it
Note: Like WordPress which has this mechanism built in (uploading multiple sizes of the image)
Unfortunately, there's no easy way to do that thanks to elFinder itself. The PHP package for elFinder doesn't have events or anything like that, for you to customize its upload behaviour. And doing it in Javascript would probably not be a good idea.
But thanks to Backpack, there's one thing you could do, that could be useful. You can use Model Events inside your CrudControllers, to do stuff after the cretate/update form has been submitted. For example:
updated
event happens, check if that file that was upload (with real dimensions) has thumbnails; if so, do nothing;So it would looks something like this:
public function setup()
{
// ...
Product::saved(function($entry) {
if (!$entry->hasThumbnailsForAttachment()) {
$entry->generateThumbnailsForAttachment()
}
});
}
Then in your Model you could create these two methods, hasThumbnailsForAttachment()
and generateThumbnailsForAttachment()
.
Hope it helps!