1

I'm reading through the Craft docs in relation to the AssetFileModel.

Looking at the getPath() method, this reads in theory that it should return the full path to the asset relative to the root, with any sub directories etc.

https://docs.craftcms.com/api/v2/models/AssetFileModel.html#getPath-detail

Yet this doesn't to appear to be the case, I seem to be getting /filename.ext

If however I was to use folderPath() this then provides the subfolder name configured in the relevant S3 asset source.

https://github.com/craftcms/cms/blob/master-v2/src/models/AssetFileModel.php#L384

Is this correct? Is getPath() meant to behave this way with S3 asset sources?

1

Seems to be working as expected for me. I've got an Asset Source setup with an S3 bucket.

At the root of the bucket, there is a test1 folder and in it is a test2 folder... i.e. root/test1/test2/. From there, I put a test.jpg file inside of test2.

When I do this from a template (where ID is the Asset ID for test.jpg:

{% set image = craft.assets.id(13).first() %}

{{ image.getPath() }}

I get the expected:

test1/test2/test.jpg
| 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.