torf Posted August 29, 2022 Share Posted August 29, 2022 I stumble upon a strange problem regarding images in rich text fields. For a section I use CKEditor for the Content. Additionally there is a imagefield for each page where inline images for this article can be uploaded. then the editor can take those images and embed them in CKEditor. In the Frontend the images are shown inline with a additional lightbox which is preformatted via ready.php: $wire->addHookAfter('TextformatterProcessImages::processImg', function(HookEvent $event) { $this->message($event); $pageimage = $event->arguments(1); $img = $event->arguments(0); if($pageimage) { $img->outertext = "<figure class='figure'><a data-fancybox='gallery' data-caption='{$pageimage->description}' class='lightboxclass' href='{$pageimage->url}'><img src='{$pageimage->size(600,0)->url}' class='figure-img img-fluid rounded' alt='{$pageimage->description}'/></a><figcaption class='figure-caption text-end'>{$pageimage->description}</figcaption></figure>"; } }); There is no Problem embedding and saving those images, but the moment a new article is published, and it has more than one image inline, the frontend gives me an "out of memory" php-error. PHP memory is set to 512MB which I think should be enough. Has anybody an idea if there is a problem that creates a loop in my script, or is it just not enough memory? Thanks for any help. PS: the problem occurs regardless of image size. If I take 12KB images or 12MB. It's always the same. Link to comment Share on other sites More sharing options...
pwired Posted August 29, 2022 Share Posted August 29, 2022 What do the server logs and tracydebugger say ? Link to comment Share on other sites More sharing options...
torf Posted August 31, 2022 Author Share Posted August 31, 2022 Sorry, I've been offline shortly. Mostly the Error occurs in wire/core/sanitizer.php on line 2555: public function entities($str, $flags = ENT_QUOTES, $encoding = 'UTF-8', $doubleEncode = true) { if(!is_string($str)) $str = $this->string($str); return htmlentities($str, $flags, $encoding, $doubleEncode); //<-- Thats line 2555 } sometimes in wire/core/Notices.php Line 523 protected function formatNotice(Notice $item) { $text = $item->text; if(is_array($text)) { $item->text = "<pre>" . trim(print_r($this->sanitizeArray($text), true)) . "</pre>"; $item->flags = $item->flags | Notice::allowMarkup; } else if(is_object($text) && $text instanceof Wire) { $item->text = "<pre>" . $this->wire()->sanitizer->entities(print_r($text, true)) . "</pre>"; //<-- Line 523 $item->flags = $item->flags | Notice::allowMarkup; } else if(is_object($text)) { $item->text = (string) $text; } if($item->hasFlag('allowMarkdown')) { $item->text = $this->wire()->sanitizer->entitiesMarkdown($text, array('allowBrackets' => true)); $item->addFlag('allowMarkup'); $item->removeFlag('allowMarkdown'); } } Link to comment Share on other sites More sharing options...
torf Posted September 15, 2022 Author Share Posted September 15, 2022 If anyone stumbles over that again - deleting $this->message($event); did the trick. Now it works. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now