Jump to:

5554 Posts in 1742 Topics by 1227 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Displaying Uploaded Images

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

Page: 1
Go to End
Author Topic: 752 Views
  • craigm
    Avatar
    Community Member
    9 Posts

    Displaying Uploaded Images Link to this post

    Hi,

    Im pretty new to SilverStripe, so excuse my ignorance but I cant figure out how to access an image ive uploaded via a custom module ive built.

    Ive created the custom module and added to it an extra field in the CMS:

    $fields->addFieldToTab('Root.Content.Main', new ImageField('Image','Upload Image'), 'Content');

    ive also added the Image field to the has_one array:

    static $has_one = array('Image' => 'File');

    Now how do i call that in the .ss file? Is there a pre built function for loading in an associated image similar to $Content

    or do i have to call a custom function that i build in the Controller of my module and return the image through it?

    if i have to build it custom, what do i need to write in there? i dont have much of an idea..

    Some help would be great.

    Cheers!

    Craig.

  • craigm
    Avatar
    Community Member
    9 Posts

    Re: Displaying Uploaded Images Link to this post

    never mind, i just changed the has_one array to:

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

    and called $Image in the .ss file

    seems to work fine

    752 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.