Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Can't view uploaded Image


Go to End


4 Posts   1924 Views

Avatar
Todd

31 Posts

31 August 2009 at 6:54am

Hi All.

I'm having a problem with my images, hopefully someone can help.

I added the following in my page.php file under the "class Page extends SiteTree":

public static $has_one = array( 'Banner' => 'Image' );

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Banner", new ImageField('Banner'));
return $fields;
}

The banner image uploads, but no picture. When I look at the source html it shows: <img src="/assets/" alt="assets/" />

What am I doing wrong?

Avatar
Willr

Forum Moderator, 5523 Posts

31 August 2009 at 9:03am

Have you rebuilt your database (www.yoursite.com/dev/build) to add the new fields for the image?. Next thing you can check is if you go into your database (with phpmyadmin or similar) and you select the 'Page' table you should see a BannerID column. Check this value - if your upload worked then this should not be 0.

Avatar
Todd

31 Posts

1 September 2009 at 11:17am

Hi Willr,

I figured it out. I has a .ss file from a previous project that was interfering with the link. Sorry for wasting your time and many thanks for the quick response and help.

Todd

Avatar
Mr V Dot

Community Member, 8 Posts

9 November 2009 at 4:28am

Edited: 09/11/2009 4:28am

Todd, what exactly was in the template file that was messing up your link? I'm having the same problem, but only have one main template (Page.ss) and as far as I can tell not even removing my includes fixes the issue. Thanks