I'm having a problem getting my asset URLs to print properly in templates. The site is using a multi-environment configuration (dev/stage/live) with localized content (en/es/da) and shared assets. Here are the config and settings.
In the config file:
define('SITE_URL', URI_SCHEME . $_SERVER['SERVER_NAME'] . '/');
define('BASEPATH', realpath(CRAFT_BASE_PATH . '/../') . '/');
return array(
'*' => array(
// common config settings
),
'site.craft.dev' => array(
'siteUrl' => array(
'en' => 'http://site.craft.dev:8888/',
'es' => 'http://site.craft.dev:8888/es/',
'da' => 'http://site.craft.dev:8888/da/',
),
'environmentVariables' => array(
'baseUrl' => 'http://site.craft.dev:8888/',
'basePath' => BASEPATH . 'http/',
),
),
'stage.site.com' => array(
// etc
),
'site.com' => array(
// etc
),
);
In the CP:
I have an 'Images' asset source defined with:
File System Path: {basePath}assets/img/
URL: /assets/img/
I have a 'printImage' asset field defined with:
- Upload Location: Images (selected in dropdown); prints (in field)
Uploading images through the CP works great, and images go to the correct folder, and are viewable in the CP.
In the template (and here is the problem), when I request the image url using {{ printImage.url }} it outputs:
when it should be:
Also, when I switch to another language it outputs:
It seems to be missing the portion of the path defined in Settings:Assets:Sources:'Images', and also is including the localization prefix.
All other paths and URLs in the site are working perfectly. Anyone have any ideas where I'm going wrong with assets? I guess I don't understand how it's crafting the asset URLs. Should I be defining an 'assetsPath' in my environment variables?
Thank you!