I have a 2 collections first is for products with preview image field (upload type) in it as well as field for other images of the product, second one to store those images -
productMediaCollection.
I wanted on image upload (for example from
productscollection) to change the name or/and file path of it to fit product title like:
or at least to change the name to something like this:
So is there a way to change default uploading name for example via
beforeValidatehook, because i dont quite understand how to do it?
Or maybe it possible to provide some function to
staticDirin
productMediaCollectionto make it conditional?
Thank for answers
There is a Github discussion on this topic:
https://github.com/payloadcms/payload/discussions/1153You should be able to handle it in a
beforeOperation
similar to marked answer.
Thank, this solution might work, but if i create hook on
productMediaCollectionthen i cant have an access to information about product from which i created a media 😦
so i cant provide a product title or something like that into hook
So i media collection hook dont knows from where it was edited last time or something like that