Like what we’re doing? Star us on GitHub!

Specify the name or path of upload

4 weeks ago

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 -



I wanted on image upload (for example from


collection) 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


hook, because i dont quite understand how to do it?

Or maybe it possible to provide some function to




to make it conditional?

Thank for answers

  • dribbens
    Payload Team
    4 weeks ago

    There is a Github discussion on this topic:

    You should be able to handle it in a


    similar to marked answer.

  • Daniq
    4 weeks ago

    Thank, this solution might work, but if i create hook on


    then 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

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More