A common problem when creating end-user content management systems using WYSIWYG editors such as CKEditor is that users can upload images within the editor, embed them, and then resize them.
After saving the content, the built-in (original) URLs of the images should be replaced by their correctly changed counterparts. Imagine a 3000 x 3000 photo uploaded by a user, manually changed in the WYSIWYG editor to 300 x 300 pixels - it needs to be automatically changed to prevent the huge source file from loading.
The task is quite simple, and I implemented it several times (although with regular expressions, so I'm looking for a replacement :)), go through the DOM, find the images, look, the size of the original image file is different from the size specified in the img tag, and if it so, replace the original image with an automatically resized image.
There are several small quirks along the way (some WYWSIYG editors prefer to use width="300" , others prefer the width: 300px CSS version, etc.).
My question is, is there a ready-made high-quality PHP solution that does this well and takes into account quirks?
source share