gordonbanderson /
responsive-mce-images
| 1 | <?php |
||
| 2 | |||
| 3 | class RemoveImageSourceAttribute extends Extension |
||
|
0 ignored issues
–
show
|
|||
| 4 | { |
||
| 5 | /** |
||
| 6 | * Remove src attributes from images, instead use foundations responsive image loader. |
||
| 7 | * |
||
| 8 | * @param string $html HTML content of the page |
||
| 9 | */ |
||
| 10 | public function ResponsiveTinyMCEImages($html) |
||
|
0 ignored issues
–
show
|
|||
| 11 | { |
||
| 12 | $dom = Injector::inst()->create('HTMLValue', $html); |
||
| 13 | if ($images = $dom->getElementsByTagName('img')) { |
||
| 14 | foreach ($images as $img) { |
||
| 15 | $cssclass = $img->getAttribute('class'); |
||
| 16 | $pos = strpos($cssclass, 'tinymce'); |
||
| 17 | if ($pos !== false) { |
||
| 18 | $img->removeAttribute('src'); |
||
| 19 | } |
||
| 20 | } |
||
| 21 | } |
||
| 22 | return $dom->getContent(); |
||
| 23 | } |
||
| 24 | } |
||
| 25 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.