2

How can I get the details of an asset volume in Craft 3, if I only know the handle?

I found the Volumes and the Assets service, but I believe none of them provides a method for that purpose. The only thing I found was this:

Craft::$app->getVolumes()->getVolumeById($id)

But how do I get the id? I do not want to iterate over getAllVolumes()...

1 Answer 1

3

As of this commit, there is a Craft::$app->getVolumes()->getVolumeByHandle($handle) method you can call.

1
  • Since Craft 4 uses a total renewed system called FileSystems instead of volumes. Whats the equivalent of this in Craft 4?
    – Kevon
    Commented Jan 17 at 13:36

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.