2

Is there a way to disable the Rich Text Editor from adding styling to images that are inserted into the field? I am specifically referring to use of the RTE in the administration portal.

For example if I add an image it automatically has:

<figure style="text-align: center;"><img alt="" src="http://www.domain.com/uploads/assets/743280d7.hero2.jpg"></figure>​

Is there a way to have it default to just showing:

<img alt="" src="http://www.domain.com/uploads/assets/743280d7.hero2.jpg">

Thanks!

2

This happens in /system/expressionengine/rte_tools/image/rte.image.js around line 75

var $img = $('<figure/>')
                .css('text-align','center')
                .append(
                    $('<img alt=""/>')
                    .attr('src', image_object.thumb.replace(/_thumbs\//, ''))
                );

It would appear the image is being wrapped in a <figure> tag to allow for alignment (left, right) and to add a caption, if present, in a nested <figcaption> tag.

Probably only way to avoid this is to edit the script.

| improve this answer | |
  • Sounds like a decent option as long as you dont require RTE in other areas. I will give this a shot and report back in a bit! Thanks – Anthony 'Ants' Nguyen Jan 17 '13 at 22:17
  • That worked great! I changed that line to: var $img = $('<span/>') .append( $('<img alt=""/>') .attr('src', image_object.thumb.replace(/_thumbs\//, '')) ); – Anthony 'Ants' Nguyen Jan 29 '13 at 0:07
  • Cool, glad it worked out for you. – erwinheiser Jan 30 '13 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.