2

I have just started using craft today and I have hit a bit of a bump with Images. I created and asset for Work and set it up to point to assets/images/work/ I was able to upload the image but when I tried to preview the 'Work' page the image was going to /work/assets/images/work relative URL I am guessing. I tried then to define and environment variable like this:

'environmentVariables' => array(
  'baseAssetUrl'  => 'http://192.168.99.100:8080/',
  'baseAssetPath' => './',
),

Updated my asset group to the following: {baseAssetPath}assets/images/work/ {baseAssetUrl}assets/images/work/

But when I try preview the page the image is broken and the variable has not been interpreted

<img src="{baseAssetUrl}assets/images/work/_360xAUTO_crop_center-center/test.jpg" alt="Test">

And I can't upload the image I get the following error message:

Upload failed for test.jpg. The error message was: “Error uploading 
the file: The file system path “{baseAssetPath}assets/images/work/” 
set for this source does not exist.”

Any ideas what am I missing?

1 Answer 1

2

It was a simple misunderstanding of how the general.php should be structured.

I had environmentVariables outside of the '*' => array(

So it's now:

return array(
  '*' => array(
    'omitScriptNameInUrls' => true,
    'sendPoweredByHeader' => false,
    'devMode' => getenv("CRAFT_DEVMODE") == "true",
    'environmentVariables' => array(
      'baseAssetUrl'  => 'http://192.168.99.100:8080/',
      'basePathPublic' => realpath(dirname(__FILE__)).'/../../html/',
    ),
  ),
);
?>
2
  • 2
    I found the answer here http://craftcookbook.net/recipes/296
    – Daimz
    Jun 13, 2016 at 5:10
  • Are you storing your assets in the root directory? My asset paths look something like this /public/assets/ or public/media/.
    – Clark
    May 9, 2017 at 22:18

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.