2

OK, So created 2 variables in my local .env file

ASSET_BASE_URL="https://mysite.local/resources"

ASSET_BASE_PATH="/Volumes/yada/yada/yada/resources"

Then in the CP, created a new Asset volume and punched in

Base URL = $ASSET_BASE_URL/gallery

File System Path = $ASSET_BASE_PATH/gallery

Then front end renders an entries asset as:

<img src="$ASSET_BASE_URL/_480x480_crop_center-center_80_none/doddle-01.jpg" alt="Doddle 01" width="480" height="480">

THEN it creates a new folder named '$ASSET_BASE_PATH' at public site root.

I'm familiar with V2 it appears V3 has stepped up a bit. Could it be a Mamp issue with paths or somesuch trickery? Works if I hard code the paths as listed initially. All help greatly appreciated.

2

For my future self, the aliases mention by nstCactus are required to reside within the '*' global setting area of general.php

'*' => [
    'defaultWeekStartDay' => 1,
    'cpTrigger' => 'admin',
    …
    'aliases' => [
    …
    …
    ]
]
2

You can't append anything to the value if you use environment variables. You need to use aliases for this.

In you config/general.php, add this:

'*' => [
    'aliases' => [
        'assetBasePath' => getenv('ASSET_BASE_PATH'),
        'assetBaseUrl' => getenv('ASSET_BASE_URL'),
    ],
],

Then in the asset volume settings, use the aliases in the Base URL & File system path:

enter image description here

1
  • Thx, updated as suggested but it still creates a folder at web root titled /public_html/@assetPath/sub_folders_etc – stuartmcd69 Sep 21 '20 at 12:12

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.