Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

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

default discord avatar
jakey___2 years 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

media

, image name is

corn-cat.png

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

/media/corn-cat.png

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.

    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.