WordPress / performance

Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.
https://wordpress.org/plugins/performance-lab/
GNU General Public License v2.0
362 stars 98 forks source link

Module Proposal: Check if image sizes set via code match the actual image sizes #470

Open pbearne opened 2 years ago

pbearne commented 2 years ago

Overview

About the module

Purpose

themes and plugins set what image sizes should be created when an image is uploaded This module would validate that actual files on the site match the values set and links to the function to rebuild if they don't

Scope

not planning to look at the actual file size but just check using the filenames

Rationale

We don't yet have the rebuild function in core so this health check should follow that into core

Other

mxbclang commented 2 years ago

Thanks @pbearne!

We don't yet have the rebuild function in core so this health check should follow that into core

Can you confirm that this would be a Health Check, or a non-Health Check module? And can you confirm that the "rebuild function" that you're referring to is #24?

cc @felixarntz @adamsilverstein for visibility

pbearne commented 2 years ago

Yes, this would be a health check module

If WP doesn't find the image size requested it has to find and sent the next size up So having the right size is a performance boost.

And yes https://github.com/WordPress/performance/issues/24 is the rebuild project for this to be linked to. It would flag that is needs to run

mxbclang commented 2 years ago

@pbearne Got it, thank you! Since #24 is still being defined, we likely won't be ready to move on this module proposal for some time. I'm going to keep this in the Backlog for now and we can discuss in a future chat as we get a little closer to that module being ready.

cc @jjgrainger @ankitrox

mxbclang commented 1 year ago

@pbearne Heads up that with the removal of WebP from core, #24 has been put on hold indefinitely, so we can't move forward on this module proposal at this time. Keeping it open and in Backlog for future consideration.

adamsilverstein commented 1 year ago

@pbearne Heads up that with the removal of WebP from core, https://github.com/WordPress/performance/issues/24 has been put on hold indefinitely, so we can't move forward on this module proposal at this time. Keeping it open and in Backlog for future consideration.

I still feel like this could be a useful module because it informs users their sizes are not set correctly. We can point to the canonical "regenerate thumbnails" plugin (or a plugin search for that phrase) to help users fix the issue

adamsilverstein commented 1 year ago

This module would validate that actual files on the site match the values set and links to the function to rebuild if they don't

@pbearne curious how you were thinking this could be accomplished. For sites with many media items, scanning every image would be costly. A scalable approach might be to only look at the oldest X images to check for correct sizes, or use a sampling approach. Neither would be completely accurate, but would still catch most cases.

What do you think?

pbearne commented 1 year ago

As I was planning to look at the file names, we could grab a few folder blobs loop to strip the filename to leave the size string and then add if different. I like the idea of just sampling, starting with the oldest

? are we going to look for images that are not needed or/and check all images we have the image sizes we need for the current theme/setup

We can stop looking once we find a mismatch we don't need a list of all the dif just to know an image is wrong.