Site logo

Archived topic

Blog add-on recreates featured images

7 replies · Started by Shane on November 3, 2015

Viewing posts 1–8 of 8

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.

Hi Shane,

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 :)

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.

Thanks,
Fotios

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.

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?

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.

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 support@generatepress.com and I'll send it your way.

Either way, I appreciate the heads up! :)

This archived topic is closed to new replies.