Upload collection hook to add an image path property to the collection?

default discord avatar
9 months ago

This is an issue I can work around, but I'm a little confused how it might be possible to, when you save an item in an upload collection, take the collection name and filename to form a relative path that would be ideal to use on a consuming app.

For instance, collection name is


, image name is


. The hook then runs when you add or update an image and somehow facilitates a value of


to the GraphQL API request for this image.

Maybe I'm doing something wrong but I'm guessing the reason why I'm not getting the upload details in a hook is because you only get the field details instead. Would I need to use plugin functionality maybe?

Came up with what feels like another work-around on this. Used the hook to copy the data contents and add a relativeUrl property. Then I query the new property instead of the original.

Curious if the generatedFileUrl is what I'll end up needing to use though... will keep posted.

    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!


    Connect with the Payload Community on Discord



    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.