-
Notifications
You must be signed in to change notification settings - Fork 0
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
Storage: Remove un-attached images #346
Comments
@Tominium What have you found out? |
Sizes found for Step 5 #1 (Sizes that are used on the site by the engage-2-x theme: |
Great Tomin! Below is a look at all the image sizes WordPress creates on upload. Are there any of these we do not need? We only want WordPress to create images we use on the site. They might be used on any page, so we'll have to go through each page and list out the image sizes used (desktop & mobile). You can view the mediaengagement.org sitemap here. Learn about sitemaps here.. ** another thing Kat had mentioned was how research article featured images were pixelated, so seems like we need to make sure the correct image size is used or check if CSS is expanding the image beyond its intrinsic size. Let me know if you have any questions, thanks for working on this! |
@luukee getting started on this again |
Thanks Tomin 🙏 |
Image sizes used by the themes, still working on other image sizes
|
According to the Regenerate Thumbnail Plugin, these are all the registered (currently used) image sizes on the dev/local version of the site: thumbnail: 150×150 pixels (cropped to fit) |
Amazing Tomin. Good info to keep on tab. We need to use a specific WordPress image size across all of our .twig templates/ This way we can narrow down the only image sizes we need and remove the extras. Reason being, with that huge list of available image sizes WordPress creates 11 image sizes every time an image is uploaded! (creates the 11 listed + the original, so 12 images). This is taking up a ton of storage on our hosting plan! TODO:Find all All the templates/ files: ( I made a list in the Projects you can edit or use Google Sheets if you'd like ) ├── 404.twig If the template file has an image we need to list what image size(s) it's using so we can filter out what image sizes we do not need anymore. I know this is a lot, maybe we should have a video chat? Let me know of your initial thoughts. Thanks! @Tominium |
These are the sizes that seem to be hardcoded in the
Will go through the actual pages now |
Gotcha. For those can you add these to the list of which files these belong to for us to reference? Thanks Tomin! |
Here are the urls and main image sizes for the |
Thanks the list Tomin. I apologize for not explaining this further. What we are looking for is a list of each .twig file's image size used (the list you found before) if it has one. For example (see image below):
So the list would be:
This way we can 1) find the places where an image size is not used and fix it & 2) once we have a list we know which image sizes, from your list are not used and remove those from the theme + delete the image files on the server. Does that make sense? Let me know. Tip:If I search the theme templates/ directory for "<img" I get 46 results: |
Yes that makes sense, will get on it! |
Great Tomin! Let me know of any questions you have :) |
Here are the image sizes I found for each |
Thank you Tomin. I added your .txt file contents to the assets/img/image_sizes/image_sizes.md file. I am preparing a couple files for you to use as an example so you can fix all of these easily :) stay tuned.... |
Updating
|
Name | Size (px) | Behavior |
---|---|---|
thumbnail | 150×150 | Cropped to fit |
medium | 300×300 | Proportionally resized |
2048x2048 | 2048×2048 | Proportionally resized |
Custom Image Sizes (Defined in src/Managers/Theme.php
)
Name | Size (px) | Behavior |
---|---|---|
featured-image | 600×0 | Proportionally resized |
carousel-image | 1280×720 | Cropped to fit |
grid-large | 404×240 | Cropped to fit |
More info:
WordPress Defaults We Are Not Using
Name | Size (px) | Reason |
---|---|---|
medium_large | 768×0 | Not needed |
large | 1024×1024 | Not needed |
1536x1536 | 1536×1536 | Not needed |
Next Steps
- Update all
<img>
elements in the.twig
files following the Before/After example. - Use the correct image size based on its usage in the theme (hero, grid, thumbnail, etc.).
- Commit your changes and push to the
feature-image-sizes
branch.
** Notes**
- If an image is used as a hero or full-width image, use
2048x2048
. - For grid post thumbnails, use
grid-large
. - Avoid using unnecessary custom sizes to keep file storage low.
Let me know if you have any questions! Thanks @Tominium
Issue: "On our WordPress site we need to identify unused images and delete them because our hosting storage plan is at its max."
Chat GPT response:
Step 1: Backup Your Site
Before deleting anything, create a full backup of your site, including the database and
wp-content/uploads
folder, in case something goes wrong.Step 2: Identify Unused Images
Option 1: Use a Plugin
Install a Plugin
Use a plugin like [Media Cleaner](https://wordpress.org/plugins/media-cleaner/) or [Advanced Database Cleaner](https://wordpress.org/plugins/advanced-database-cleaner/).
Run a Scan
Review the List
Option 2: Use WP-CLI (Advanced)
If you are comfortable using WP-CLI, you can list unattached media files:
This will show images that are not attached to any post or page.
Option 3: Manual Review (Time-Consuming)
Step 3: Delete Unused Images
Using Plugins:
Using File Manager or FTP:
Use cPanel's File Manager or an FTP client like FileZilla.
wp-content/uploads/
Review old image folders for unused or orphaned files.
Cross-check files before deleting to ensure they’re not hardcoded in themes or custom post types.
Step 4: Optimize Remaining Images
remove_image_size
function in your theme'sfunctions.php
.Step 5: Prevent Future Clutter
Figure out what image sizes are not used in our theme
First we need to find what image sizes are used for each page in our theme code. Image sizes in WordPress
Disable Unnecessary Image Sizes:
Add this to your
functions.php
file to prevent WordPress from generating certain image sizes:Use a Media Library Organization Plugin:
Plugins like [Media Library Organizer](https://wordpress.org/plugins/media-library-organizer/) can help keep your media library clean going forward.
Final Recommendations:
The text was updated successfully, but these errors were encountered: