junaidbhura / fly-dynamic-image-resizer

Fly Dynamic Image Resizer plugin for WordPress
https://wordpress.org/plugins/fly-dynamic-image-resizer/
MIT License
161 stars 26 forks source link

performance issue #15

Closed simonpeters closed 7 years ago

simonpeters commented 7 years ago

Hi,

I'm using the fly_get_attachment_image_src method to crop images on the fly. But it seems like it crops them on every visit and doesn't fetch them from the cache the second time. (the load time is about 5 seconds each page hit).

Is there a way for me to debug whats going on? I'm using version 2.0.2

junaidbhura commented 7 years ago

@simonpeters Thanks for raising the issue. The plugin does, in fact, load the image from the cache. This means your issue could be:

If you want to debug this, you can do it from the function get_attachment_image_src in the JB\FlyImages\Core class. You can see that it checks if the cached file exists first, and if it doesn't, it creates it.

simonpeters commented 7 years ago

Seems like it does hit the cache but the wp_get_image_editor calls slows it down. I'm running locally on my macbook so not sure where the performance issue is coming from. thanks for the help!

junaidbhura commented 7 years ago

@simonpeters I've created a new pull request for this: https://github.com/junaidbhura/fly-dynamic-image-resizer/pull/16 from a branch called "performance".

I've used getimagesize directly instead of wp_get_image_editor. Here's the commit: https://github.com/junaidbhura/fly-dynamic-image-resizer/commit/430519aba8b1e4e3068b377aa4f05caf8e0cf523.

Can you test this out at your end and let me know if this reduces the performance issues?

simonpeters commented 7 years ago

hey @junaidbhura, I just tried it out and I got a speed increase of about 400%!

Thanks

Also might I suggest giving the option to skip getting the height and width? I currently don't need it and it might increase performance even more.

junaidbhura commented 7 years ago

@simonpeters That's an impressive improvement! I'll merge these changes in and release an update.

The fly_get_attachment_image_src is modeled on wp_get_attachment_image_src so devs can build an image tag.

We can probably re-visit this at a later stage and see if this comes up again.

Thanks again for raising the issue!