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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

How can I stop Tinymce insert height and width attributes to my images?


Go to End


4 Posts   6719 Views

Avatar
mrsteveheyes

Community Member, 15 Posts

25 October 2013 at 11:45pm

Hi there,

Currently, when I add image through the TinyMCE image insert function it adds a height and width attribute to the <img> tag. I want to stop that, as it a responsive site and so need the image to be flexible.

Is this possible? Has anyone done it before or know how?

Thanks in advance,
Steve

Avatar
kinglozzer

Community Member, 187 Posts

26 October 2013 at 12:31am

Hi Steve,

I've not found any way of preventing that, but I've overcome it before using CSS. Usually, giving img a max-width: 100%; and height: auto; will solve it - browsers seem to ignore the width/height attributes when 'height: auto' is applied.

Hope this helps,
Loz

Avatar
Nachos

Community Member, 22 Posts

29 January 2015 at 7:53am

Edited: 29/01/2015 7:54am

Thanks Steve and kinglozzer! But isn't there a way to modify the cms insert image function? I'd like to be able to define the class options available in the dropdown and leave out height and width to work with responsive width. I found a solution for 2.4. modifying ThumbnailStripField.php, which is deprecated. Anyone knows where can I find those controllers in 3.1.?

Avatar
Rob Clarkson

Community Member, 26 Posts

21 April 2015 at 11:28am