Last active
November 18, 2015 21:32
-
-
Save jenswittmann/13448acf1930639beca1 to your computer and use it in GitHub Desktop.
MODX Redactor replace inline CSS and add SrcSet: http://jens-wittmann.de/codeschnipsel/redactor-editor.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$o = $input; | |
// replace inline css | |
$o = preg_replace('/(<[^>]+) style=".*"/iU', '$1', $o); | |
// remove paragraph around img and iframe | |
$o = preg_replace('/<p>\s*(<img.*>)\s*<\/p>/iU', '$1', $o); | |
$o = preg_replace('/<p>\s*(<iframe.*>\s*<\/iframe>)\s*<\/p>/iU', '$1', $o); | |
// add srcset | |
$o = preg_replace('/<img src="(.*)".*>/iU', '<img src="[[pthumb? &input=`$1` &options=`w=1000`]]" srcset="[[pthumb? &input=`$1` &options=`w=500`]] 500w, [[pthumb? &input=`$1` &options=`w=1500`]] 1500w" $2>', $o); | |
return $o; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment