Lorti / dominant-colors-lazy-loading-wordpress-plugin

This plugin allows you to lazy load your images while showing the dominant color of each image as a placeholder – like Pinterest or Google Images.
https://wordpress.org/plugins/dominant-colors-lazy-loading/
GNU General Public License v2.0
95 stars 10 forks source link

Processing of a large number of attachments fails #5

Closed samburgers closed 8 years ago

samburgers commented 8 years ago

Hi,

Great plugin. When trying to use it on a site with thousands of existing images, the settings page fails altogether with a memory allocation error, and thus becomes unusable.

Could i suggest that the images calculate the dominant color upon image upload, rather than try and do it all at once?

Many thanks!

Lorti commented 8 years ago

Hi Sam,

I am not entirely sure that I understand your problem correctly, I am afraid. The colors do get calculated on upload – the function is hooked to the add_attachment action. The settings page lists all existing images without dominant colors, which are all the images that have been uploaded prior to activating the plugin. Can this cause a problem?

How much images are we talking about? I have successfully recalculated a batch of 4073 images on my company's blog. The script itself opens a single request for each image, so a memory allocation error in the calculation itself is unlikely. I am guessing that the list markup itself becomes too long and kills the page. Can this be the case?

Kind regards, Manuel

samburgers commented 8 years ago

Hi Lorti,

Thanks for the reply. About 100,000 items in the media library. Its a DB level error, so if it attempts to list all the media items in one go, its not surprising it fails. Perhaps staggering this to a couple of hundred items at a time would be a better idea? Also, separating that functionality into a different page tab from the main settings page might be a good idea.

Many thanks

Lorti commented 8 years ago

Thanks, that is a different order of magnitude 😄

You are definitely right, I have to rethink the batch itself. In the meantime I will follow your suggestion and move the recalculation to a different tab, so one can access the general settings.

Lorti commented 8 years ago

This should be fixed in Version 0.5.4. Would you be so kind as to update the plugin and try it on your images?

samburgers commented 8 years ago

Works well here, thanks!