0

I posed this question in the Craft Help Slack channel earlier but still don't have resolve.

Background on my field setup:

Entry - Matrix -- Image Block (matrix.imageBlock) (assets) --- Mobile Image field (mobileField) (assets)

The image block field in the Matrix is using a restricted upload folder {owner.slug}; which is the entry slug (so its saved to /uplaods/entrySlug/). I also have a child asset field added to the image block to add a mobile specific image. Prior to Craft 2.5, using {folder.path} would put those images into the same /uploads/entrySlug/. Now when I "double click" the asset field to add the mobile image, {folder.path} returns This field’s target subfolder path is invalid: {folder.path}.

I was given a few ideas to pursue as it was thought that maybe the dynamic path had not resolved yet, but they didn't work.

I'm thinking that it does indeed revolve around dynamic paths, however, I can't seem to figure it out. All I'm looking to do is save the child asset field files to the same directory that all the other images go to (one image bank, so to speak, for the entire entry).

  • I voted to close as off-topic (a Craft bug). You should probably report it to P&T, so they can look into this. – carlcs Jan 27 '16 at 1:16
  • Is mobileField inside of Matrix? I can't tell from the description. – Brad Bell Jan 27 '16 at 3:04
  • @BradBell it is only b/c it's added to the imageBlock. It is a standalone Assets field that I've added to the imageBlock Assets field which is a block in the Matrix. – Ryan Shrum Jan 27 '16 at 14:47
  • So it's an Assets field, on an Assets field, inside of Matrix, right? – Brad Bell Jan 27 '16 at 20:11
  • @BradBell That's right! – Ryan Shrum Jan 27 '16 at 20:16
4

For long and complicated reasons, in order for this to work after Craft 2.5, your inner Asset field (the one that was restricting uploads to {folder.path}, will need to {folder.path|trim('/')} instead.

| improve this answer | |
  • Glad that there's a workaround. Would this still be considered a bug? – Lindsey D Jan 28 '16 at 17:03
  • Possibly? Can't really think of a fix (clean or otherwise) for it at the moment, so I've vote to leave it open. Pretty edge case, but someone else might run into it. – Brad Bell Jan 28 '16 at 18:44
1

I guess it is a bug. Calling getFolder on an asset model returns an asset folder model, but it somehow looks like its path property always returns an empty string.

I tested this with local and S3 assets:

{% set asset = craft.assets.id(217).first() %}
{% set folder = asset.getFolder() %}

{{ folder.path }}
{{ dump(folder) }}
| improve this answer | |

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.