- This topic has 7 replies, 3 voices, and was last updated 5 years ago by Tom.
November 3, 2015 at 8:37 pm #150265Shane
I’m the developer of the EWWW Image Optimizer, and one of my users was having a problem with images being regenerated repeatedly, and we finally narrowed it down to the Blog add-on for GeneratePress. The function claims that it will serve an existing image or create a new one, save it to disk, and then serve that. The reality is that every single page load triggers creating a new image, saving it to disk, and then serving it.
In perusing the code, the reason is that gambit_otf_regen_thumbs_media_downsize() does something entirely different depending on whether $size is a string or an array. In my testing, $size = ‘generate-plus’ (a string), and that section of code never checks to see if the file actually exists.
I’m sure folks would appreciate a bugfix on that, as regenerating every featured image on every page load would certainly cause extra load on a server, and reduce page loading speed as well.November 3, 2015 at 11:47 pm #150273TomLead DeveloperLead Developer
Thanks for bringing this to my attention – I really appreciate it.
I’ll check to see if it’s something on my end that needs tweaking or if it’s within the resizing script itself (https://github.com/gambitph/WP-OTF-Regenerate-Thumbnails).
If you’re aware of any other on the fly WP resizers – I’m all ears!
Thanks again 🙂November 5, 2015 at 12:13 am #150569Fotios Nisiropoulos
Hi Shane, Hi Tom,
thank you so much for taking care for that problem!
I hope that you find a fix for my issue, as it drove me crazy for a few weeks.
If you need some testing of the fix from my side then just drop me a note.
FotiosNovember 5, 2015 at 10:12 am #150746TomLead DeveloperLead Developer
I believe this is a bug with the actual script: https://github.com/gambitph/WP-OTF-Regenerate-Thumbnails
I’ve looked into how we’ve implemented it and can’t see anything I can do any different.
I’ll look around for an alternative image resizer.November 5, 2015 at 10:16 am #150747Shane
Or you could just add in a check to the file_exists() function with the image filename before it actually generates the resize in that code block.November 5, 2015 at 10:48 am #150765TomLead DeveloperLead Developer
Add that check into the otf_regen_thumbs.php file? I’ve checked though the file and it does seem to check to see if the image exists before generating it, although it doesn’t use the file_exists() function like it does if the size is an array.
Maybe it would be best if I just served the sizes as an array instead of a string – that way I don’t need to touch the script.
How did you test to see if the script was re-creating the image on every load?November 5, 2015 at 6:57 pm #150835Shane
Yeah, now that you mention it, it probably would be easier to just pass in an array with the dimensions. The filename doesn’t really exist as a variable prior to the resize function in the other section of the code, so you’d have to find a way to figure out what the name is GOING to be before you can even check to see if it already exists.
I tested it via a debugging function I have in EWWW Image Optimizer, just added a couple extra lines in on my local dev install of WP, and then I could see that every time I refreshed the page, it was sending an image through the WP_Image_Editor functions that EWWW hooks into.November 5, 2015 at 11:50 pm #150862TomLead DeveloperLead Developer
I’ve gone ahead and made the adjustments to call the resizer using an array instead of a string – hopefully it fixes it.
If you want to give it a test just let me know at email@example.com and I’ll send it your way.
Either way, I appreciate the heads up! 🙂
- You must be logged in to reply to this topic.