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.

Customising the CMS

Resize images on-the-fly in content?


2 Posts   967 Views


30 March 2011 at 11:38pm (Last edited: 30 March 2011 11:38pm), Community Member, 102 Posts

How can I enable SilverStripe to resize images inserted into the TinyMCE editor? I mean SilverStripe resizing them on the server, not by setting HTML attributes.

e.g. Images in a slideshow are automatically resized on-the-fly by $photo.SetWidth. But when inserting the images into content, they need to be resized using desktop photo editing software. It's very time consuming and painstaking, with lots of steps. I trained a new client recently and they were fine with SilverStripe, but they found resizing photos difficult.

If images were represented by a shortcode (like links) instead of the raw HTML, then the CMS image insert could store the required sizes along with the image ID. (As a positive side-effect, image files could be moved/renamed in 'Files and images' and URLs automatically updated.)

Alternatively (and even easier for the user), if the required size of images for a particular content area is known (e.g. in the right column, images are always 200 wide) then that size could be a property of the field, and used to automatically resize the image when the shortcode is processed. The same result could be achieved without shortcodes by parsing the HTML and replacing image file names, but that's just nasty.

I think there was an attempt at an on-line image resize/crop feature in 'Files and Images' but it was scrapped, right? Is that coming back? A simpler alternative would be the ability to resize an image simply by entering it's new dimensions. However, on-the-fly resizing is better, because if the original is changed, all resized variants are updated automatically.



31 March 2011 at 8:07am Forum Moderator, 474 Posts

On the first save after they've been inserted, if the image has been given a width/height, the image gets resized. I'm not sure if that covers future resizes though.