I would like to know how to use file.create:after to duplicate a file into two other folders automaticaly.
When an image is uploaded into ‘home’, I want it too into ‘views’ and ‘works’ pages.
Is it possible with hooks like these first lines ? Does anyone already did this somewhere ?
'hooks' => [
'file.create:after' => function ($file) {
...
},
'file.replace:after' => function ($newFile, $oldFile) {
...
}
]
You probably also want to delete the file when it is deleted? In that case you need an additional hook.
And in the replace hook, you would also have to delete the original file and then create the new file.
Just wondering why you are duplication the files into other pages instead of querying them from the home page? Would reduce the chance that something goes wrong.