Jump to:

3373 Posts in 998 Topics by 712 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: 964 Views
  • pinkp
    Avatar
    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

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

    MyPage.php

    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
    964 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.