Photo.URL doesnt work

Hi I created DataObject - Banner:


use SilverStripe\ORM\DataObject;
use SilverStripe\Assets\Image;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\AssetAdmin\Forms\UploadField;

class Banner extends DataObject {
    private static $db = array (
        'Nadpis' => 'Text',
		'Popis' => 'Text',
		'Link' => 'Text',

    private static $has_one = array (
        'Obrazok' => 'Image',
		'Page' => 'Page'
	 private static $summary_fields = array (
        'GridThumbnail' => '',
        'Nadpis' => 'Nadpis',
		'Popis' => 'Popis',
		'Link' => 'URL adresa odkazu',

    public function getGridThumbnail() {
        if($this->Obrazok()->exists()) {
            return $this->Obrazok()->ScaleWidth(100);

        return "(no image)";

    public function getCMSFields() {
        $fields = FieldList::create(
            $uploader = UploadField::create('Obrazok')


        return $fields;

class Banner_Controller extends PageController {

And I add it on Homepage:


use SilverStripe\Forms\TextField;
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;

class HomePage extends Page {
    private static $db = [
		'Box1' => 'HTMLText',
		'Box2' => 'HTMLText',
		'Box3' => 'HTMLText',

    private static $has_one = [];
	private static $has_many = array (
		'Bannery' => 'Banner',

	public function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldToTab('Root.Main', $Box1Field = HtmlEditorField::create('Box1','Box pod bannerom 1'),'Content');
		$fields->addFieldToTab('Root.Main', $Box2Field = HtmlEditorField::create('Box2','Box pod bannerom 2'),'Content');
		$fields->addFieldToTab('Root.Main', $Box3Field = HtmlEditorField::create('Box3','Box pod bannerom 3'),'Content');
		$fields->addFieldToTab('Root.Bannery', GridField::create(
            'Vloženie banneru na úvodnú stránku',
		return $fields;

But When I call URL on I get empty string. “Nadpis”, “Popis” and “Link” having good value.

LINK on page:

A couple of things which are possibly the issue:

In your has_one relations, you’d be better off using the full classname, eg:

private static $has_one = [ 'Obrazok' => Image::class, 'Page' => Page::class ];

(And the same in your HomePage class too)

You haven’t posted your template code, so it’s a bit of guesswork here. Bannery is a has_many relationship, so it will return a data list, meaning you can’t just access a URL without more info.

What I think you’ll need is something like $Bannery.First.Obrazok.URL in order to get to the image. If that doesn’t work, can you post the relevant part of your template and hopefully it will be clearer.

Thx. ::class worked. I also change Photo.URL for Photo.Link and delete widht for Image, because I used SS 4.2.1