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.

Data Model Questions /

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

Method for controlling Image Size from CMS for SlideShow

Go to End



Community Member, 182 Posts

13 June 2010 at 8:05am

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

<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[]=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