-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to clear cache of user meta to remove image sizes that do not exist #90
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thrijith In this PR, we're deleting cache for the current admin user, normal users can't delete the cache because they don't have access to the setting page. Besides, the main usage of this feature is deleting the cache after regenerating thumbnails, which only admins can perform.
I think the deleting cache function should delete the avatar cache for all users instead. We also need to care about the performance of large sites that have many users.
@dinhtungdu I've made some changes, please check again when you get a chance, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thrijith This is likely to have timeout issues IMO. For large sites with a lot of users, it would take time to get all users, check and update the meta for each user. We're doing everything in a page load, which is not reliable to me. I think Ajax can be the solution to this issue.
@dinhtungdu please check again when you get a chance, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assets/js/admin.js
Outdated
} | ||
}, | ||
error : function () { | ||
alert(slaAdmin.error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the message span below the button, demo https://cln.sh/u5NhwT
} | ||
} | ||
|
||
if ( ! empty( $rows ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating $row
to hold only user IDs, I think we can use the $users
variable above to check for the end of the progress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dinhtungdu I've updated this, please check again when you get a chance, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Left an optional comment but this is ready to be merged!
Co-authored-by: Tung Du <[email protected]>
Description of the Change
Clear Cache
button inSettings
->Discussion
, which updates the user meta to remove images that don't exist.Alternate Designs
N/A
Benefits
Possible Drawbacks
N/A
Verification Process
Regenerate Thumbnails
pluginTools
->Regenerate Thumbnails
, selectDelete thumbnail files for old unregistered sizes in order to free up server space. This may result in broken images in your posts and pages.
checkbox and regenerate the thumbnails.Settings
->Discussion
and use theClear Cache
to fix the issue.Checklist:
Applicable Issues
Fixs #31
Changelog Entry
Clear Cache
button to fix broken avatar images after thumbnail regeneration.