created css text filter to clean all style attributes in content

This commit is contained in:
2018-04-15 15:19:19 +02:00
parent efca592b17
commit df54d07169
4 changed files with 47 additions and 0 deletions
@@ -0,0 +1,36 @@
<?php
namespace Drupal\edlp_admin\Plugin\Filter;
use Drupal\Component\Utility\Html;
// use Drupal\Component\Utility\Unicode;
// use Drupal\Component\Utility\Xss;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
// use Drupal\Core\Url;
// use Drupal\Core\Template\Attribute;
/**
* Provides a filter to convert audio links.
*
* @Filter(
* id = "css",
* title = @Translation("Css remove filter"),
* description = @Translation("Remove all style attributes"),
* type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE
* )
*/
class CssFilter extends FilterBase {
/**
* {@inheritdoc}
*/
public function process($text, $langcode) {
$result = new FilterProcessResult($text);
$cleaned_text = preg_replace('/style="[^"]*"/i', '', $text);
$result->setProcessedText($cleaned_text);
return $result;
}
}