0

I've seen this post: Remove inline styles from WYGWAM - but it's for WYGWAM. Has anyone successfully changed CKEditor's behavior, from Wyvern, to output this:

<img src="blat.gif" height="200" width="200">

Instead of this:

<img src="blat.gif" style="width:200px; height:200px;">

It's not clear which file I should edit.

  • You should be able to write some jquery that will do that for you on the fly. – CreateSean Jul 22 '15 at 17:14
1

Hrmm. I wouldn't recommend changing core files.

:p I feel like being awful today. Here's a PHP solution (turn template on PHP output):

<?php
echo preg_replace("/height\=\\"(\d*)\\" width=\"(\d*)\\"/", 'style="height:$1px; width:$2px;"', '{wyvern_image_field}');
?>

This regex will turn

<img src="blat.gif" height="200" width="200">

to

<img src="blat.gif" style="height:200px; width:200px;">

bunch of edits that was some quote nightmare to get right, lol. AND OH, woops, you wanted it to go the other way. Hold on, regex coming up in a few minutes!

Here ya go, buddy!

<?php
echo preg_replace("/style=\\"height:(\d*)px; width:(\d*)px;\\"/", 'height="$1" width="$2"', '{wyvern_image_field}');
?>

This will take this

<img src="blat.gif" style="height:200px; width:200px;">

and produce this!

<img src="blat.gif" height="200" width="200">
| improve this answer | |
1

Wyvern has a similar config file, you can add this line to it:

config.disallowedContent = 'img{width,height}';

| improve this answer | |
  • I added to line 38 of /themes/third_party/wyvern/config.js? but the field is not responding. – 4midori Jul 22 '15 at 21:10

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.