3

I have a Matrix field with four blocks currently, a header (text), explanation (rich text), slideshow (assets), and single image (assets). Both the slideshow and single image blocks have two fields, image and caption.

The image field is the same in both with the exception of the slideshow assets field allows multiple images to be uploaded while the single is obviously limited to one. Both have "Restrict uploads to a single folder?" and "Restrict allowed file types?" checked and the latter only allows images. Both also have the same Asset Location selected and {owner.slug} as the path. Recently I discovered that I can no longer upload images to {owner.slug}, instead Craft is trying to upload images to /craft/storage/runtime/assets/tempuploads/field_##.

I've checked file permissions for my assets directory and there shouldn't be a problem writing to it. I used to be able to create subfolders based on the entry slug and what's even more bizarre is that I can edit an existing single image or slideshow block image field and it will use/upload to the proper directory.

Any ideas why it would stop doing this?

  • Hey Stuart, this may have been related to a bug we just fixed in today’s update. Can you try updating? – Brandon Kelly Jul 23 '14 at 21:06
  • Updated and still having the same issue. – Stuart McCoy Jul 24 '14 at 4:06
2

According to Andris this is the expected behavior in this situation. The bug fix does make Craft work as intended but creates a slightly confusing workflow if you don't know what to expect. The good news is my expected behavior, which is to have assets available if {owner.slug} has been created in my assets folder already, is on the official list of features to implement. Well, assuming Andris doesn't go into a drunken stupor and forget to tell Brad or Brandon.

  • We talked about it :) We’re going to look into special-casing Matrix blocks. – Brandon Kelly Jul 24 '14 at 15:39
  • Hey @BrandonKelly I'm pretty confused on this issue. I was using a very similar setup to Stuarts - the differences were I had an asset folder setup on a Rackspace CDN and was using just {slug}. This was working properly before Craft 2.1.2566 and was uploading the files to my CDN appropriately... but after the update the files are going all over the place including places like /cpresources/tempassets/field_67/ and when they do hit the CDN they're being uploaded to the root folder and not the one involving the {slug}. Could you shed a bit more light on what the expected behavior is? – Ian Jul 24 '14 at 17:33
  • 1
    @Ian If it’s within a Matrix field you should be using {owner.slug} rather than {slug}, since the element that your Assets field is attached to is a Matrix block, not the entry, and Matrix blocks don’t have a slug. Calling owner will give you the parent element that the block is attached to (the entry, in most cases). – Brandon Kelly Jul 24 '14 at 17:42
  • That did it. Does that mean that 'owner' pertains to the entry the Matrix is in? – Ian Jul 24 '14 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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