1

I have a towns entry with a matrix field: townAlbums.

This matrix field has just one block type: photoAlbum.

This one block type has two basic text fields (the important one being albumName and one asset field for uploading images to the gallery: albumPhotos.

I want the Default Upload Location for this matrix subfield albumPhotos to be dynamic, taking both the parent entry slug (slug of the town entry) and the name of the album: albumName. I'm not sure how to accomplish this.

Desired url:

http://sitename.com/uploads/towns/town-slug/album-name/filename.jpg

What should I be entering for my Default Upload Location?

Thanks!

1 Answer 1

3

If your desired URL is:

http://sitename.com/uploads/towns/town-slug/album-name/filename.jpg

The the "Upload Location" for the setup you described would be something like:

towns/{owner.slug}/{albumName}/

I'm assuming towns is just hard-coded since you're referencing town-slug in the next segment.

3
  • This did create the right directory structure, but the uploaded photos end up getting saved in the root uploads/ directory, not the towns/town-slug/album-name/ path it successfully created. Commented Feb 8, 2018 at 14:32
  • Weird... something else must be going on. Tested locally and it worked.
    – Brad Bell
    Commented Feb 8, 2018 at 21:11
  • Not sure what has changed since. Maybe something in one of the recent Craft updates?? In any case, I just tried your suggestion again and can confirm it's working on my end now. Thanks!! Commented Mar 18, 2018 at 1:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.