Source of file HtmlEditorField_Extension.php
Size: 1,423 Bytes - Last Modified: 2021-12-23T10:59:03+00:00
/var/www/docs.ssmods.com/process/src/code/HtmlEditorField_Extension.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344 | <?php /** * Add 'no alignment' option when inserting images through 'Insert Media' form. */ class HtmlEditorField_Extension extends Extension { public function processImage($image, &$imageDom) { // create the sizes of responsive images to be shown $resized640 = $image->SetWidth(640); $resized720 = $image->SetWidth(720); $imageDom->setAttribute('data-src-640', $resized640->URL); $imageDom->setAttribute('data-src-720', $resized720->URL); // remove width and height attributes as they break the view in the editor $imageDom->removeAttribute('width'); $imageDom->removeAttribute('height'); $parent = $imageDom->parentNode; $parentClass = $parent->getAttribute('class'); if (strpos($parentClass, 'captionImage') !== false) { $parent->removeAttribute('style'); } /* not winning with this other than attribute tweaking $html = $image->renderWith('TinyMCEImage'); error_log($html); $htmlValue = Injector::inst()->create('HTMLValue', $html); error_log($htmlValue); $htmlDom = $htmlValue->getDocument()->documentElement; error_log('HTML DOM:'.get_class($htmlDom)); $imageDomNode = $imageDom->nodeValue; $htmlDomNode = $htmlDom->nodeValue; //$imageDom = $htmlDom; $imageDom->appendChild($htmlDom); */ } } |