this is my page
page.htm (Markup) - I manage to get the image name but I can't get the image source
<img id="avatar-image" alt="Jason's Image" src="{{ avatar_id }}"/>
{{ file_name }} // working
{{ avatar_id }} // not working
page.htm(Code)
function onStart()
{
$var = \System\Models\File::where("field", "=", "avatar")->first();
$this["file_name"] = $var->file_name;
$this["avatar_id"] = $var->path;
}
my model
model.php
class Settings extends Model
{
public $implement = ['System.Behaviors.SettingsModel'];
public $settingsCode = 'dca_plugins_settings';
public $settingsFields = 'fields.yaml';
public $attachOne = [ 'avatar' => ['System\Models\File'] ];
}
field.yaml
fields:
id:
label: ID
disabled: true
name:
label: Image
avatar:
label: Avatar
type: fileupload
mode: image
imageHeight: 150
imageWidth: 250
can someone tell me how to get the path(image source)?