3

I have an Asset Source, called files, with two subfolders:

  • group1
  • group2

I also have two User Groups, with the same names.

I want everyone in “group1” to save images into files/group1; and I want everyone in “group2” to save images into files/group2.

I have a Matrix field which contains an Assets field. It is configured to:

  1. Restrict uploads to a single folder => files/{owner.author.groups[0].name}/images
  2. Restrict file types to Image

When a user from group1 logs in and adds an entry, the image asset folder doesn't display all the data from their images folder.

If I upload images in the Assets folder directly to their images folder and go back to create a new entry, the new image doesn't show up in the image list.

Any ideas what is going on?

1
  • Please note: all images are being added via the CP. I am not adding any of these files via FTP
    – Sandy D.
    Commented Oct 8, 2015 at 17:41

2 Answers 2

4

Okay. So, my problem was that I had multiple Asset Sources since I was trying to give my groups permissions to specific sub-directories. This was causing indexing issues which is why I wasn't seeing the images show up.

CraftCMS has an excellent customer support. They were able to create a plugin that allowed me give my groups permissions to their subdirectories.

Link to plugin: https://github.com/pixelandtonic/AssetSubfolderAccess

All you have to do is create your user groups. Then create an asset source configuration that points to your root folder that will contain the subdirectories. Give your user groups permission to the Asset Source (Root folder).

Then on the plugin page after you have installed the plugin. Click on the plugin to go to its settings. This is where you can configure each of your user groups to only have access to their sub-folder. =)

Huge thank you to CraftCMS, Pixel And Tonic, and Brandon for all the help. You guys are amazing!!! =)

2

This is happening because currently it’s not possible for Assets fields to resolve those dynamic subfolder paths until the element the field is associated with has been saved (in this case, your Matrix block).

If you create a new block, click the “Save and continue editing” button (or Command/Ctrl + S), then you should be able to see all of the existing images within the dynamic subfolder.

Update

As of Craft 2.4.2697, Craft now does attempt to resolve dynamic subfolder paths. If there’s nothing that requires that the element already be saved (e.g. {id}), it will go ahead and use the resolved path rather than the temp folder.

3
  • I do save it first. The directories never match up. If I add files via the Assets at the top of the Control Panel, the files there never show up in the Matrix Block Asset Field (even after I have saved). If I upload a new file via the Matrix block, the new files don't show up in the Asset Directory listing. The directories never match up -- even though on my file system - the files are there.
    – Sandy D.
    Commented Oct 8, 2015 at 22:13
  • @BrandonKelly will the asset fields be able to resolve those paths anytime soon? Clients think this is a bug and I'd say it actually is. If you have a required image field and the client can't select an image from previously uploaded assets then that image select field doesn't really work. I guess I could create a twig function that looks at the URI or anything available to determine what the owning entry is to get owner.slug without having saved yet. It would be nice if it just worked out of the box though.
    – Justin
    Commented Oct 14, 2015 at 15:04
  • 1
    @Justin Had another look at the code and thought of a good way to solve this, at least some/most of the time. The change has been included in today’s 2.4.2697 release :) Commented Oct 15, 2015 at 20:04

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.