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