- This topic has 3 replies, 1 voice, and was last updated 1 week, 2 days ago by GlitchyDragon65.
- January 13, 2021 at 2:30 pm #5733gh0st_FrParticipant
With my colleague, we are in a site speed optimization period, deleting unused plugins, calling scripts only where they’re need etc…
Now, it’s time to gain space with images. Our WordPress has hundreds of pics but, we need juste 30-40% of them. I know that plugin exist but :
* little bit scared to let plugin delete things in the database
* personal challenge !
* trying to understand a little bit more how WordPress works
So I search how to do that myself and set up few steps.
1. Sort used and unused images
2. Where and how delete unused pics in the database
3. create a new uploads folder with only the pics we need
I have created a script that performs all these steps (you can look and try it on my Github > [https://github.com/yannis94/sort_images](https://github.com/yannis94/sort_images) )
Everything works, the script creates a new uploads folder and a SQL script, but I’m still doubtful.
The next step is to execute the SQL script on the server and replace the uploads folder, I’ve tried it locally and it works, but stay a little bit scared to do that on my company’s web site ^^.
I still hesitate to fell very smart and proud of it or the total opposite, can you guys tell me what do you think about that process and if you think that it will works ?
If you are interesting to update my script or giving some tips, I will be glade of thisJanuary 13, 2021 at 2:30 pm #5734xhr2Guest
Seems like you’re on the right track but why are you copying the used images to a new folder? Your SQL scripts don’t update their paths in the database so it seems this step is redundant.January 13, 2021 at 2:30 pm #5735legen_dar33Guest
Always happy to see new development, but if you decide to go with a plugin in the end, this one has worked well for me. It puts deleted files into a temp folder, so that if stuff is missing from your site, you can restore the files before deleting them completely.January 13, 2021 at 2:30 pm #5736GlitchyDragon65Guest
If your using wordpress use should use Smush or else you can see the source code by downloading you can search at wordpress.org
- You must be logged in to reply to this topic.