Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Method for controlling Image Size from CMS for SlideShow

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

Page: 1
Go to End
Author Topic: 1018 Views
  • pinkp
    Community Member
    168 Posts

    Method for controlling Image Size from CMS for SlideShow Link to this post

    What is the best way to generate an image in ratio where the width or height is controlled by the user in the CMS and the other value is generated for use in the template. Attached is the whole Slide Show mod in its current form an extension of DOM if anyone wants to help...

    I currently have MyPage.ss

    <img src="$SlideshowImage.URL" width="$ShWidth" title="$ShTitle" alt="$ShTitle" />


    static $db = array(
              'ShWidth' => 'Int'


       public function getCMSFields()
          $f = parent::getCMSFields();
        $f->addFieldToTab("Root.Content.SlideshowConfiguration", new NumericField('ShWidth','Slideshow Width (pixels)'));
       return $f;


    This works and the image automatically creates the correct height after the user chooses the width....

    I know there is a lot of ways here http://doc.silverstripe.org/image?s[]=width&s[]=ratio

    But I want the user to control the title and due to the way this slideshow script works I would like to have the height automatically generated after the user has chosen the width so the value is added to the template dynamically as I need to set the width of the div in order to be able to centre it and as it needs to have "position: absolute;" I need the height value to add to the div or the text disappears under the image...

    Attached Files
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.