The whole process of registering and using GitHub Pages
view my personal blog original article for more:
https://alvincr.com/2021/01/clear-thumbnail/
0 ready
0 reason
As I tested and used Smush, a super large number of thumbnails were generated in the directory of the alvincr.com website, which caused the size of the picture to change from 160M to 600M. However, after using it for a few days, I found that Smush saved a total of 15M bandwidth (14%) , Although you can choose the number of thumbnails generated in the settings, I personally think that this plugin does more harm than good.
Then I set up in the software to automatically clear the thumbnails after uninstallation, but when I uninstalled, I found that the thumbnails were not automatically deleted at all, or remained in the original folder, so I had to find a way to solve this problem.
1 Must be backed up to avoid problems
Packaging instructions-tar
The Tar instruction is used for packaging rather than compressing files, so the files will be larger.
For example, use tar -zcvf alvincr.com.tar alvincr.com
-v generates detailed file information, -c to create a new archive file, -f to use archive file or equipment. When in use: It can run regardless of whether it is added or not. It is invalid to use tar -zcvf alvincr.com directly. If you use -z then gzip will be used for compression.
Using the -z parameter will generate a file ending in tar.gz. Comparing the two files, you can see that the size of the alvincr.com file generated in the same time period is different (where the tar1 ending is a website that does not use gzip compression)
Download command -sz
If it is not installed, you can use yum install lrzsz to install, and other download methods can be searched on the homepage of the site: Quick sharing of Win and Linux files
Download from Linux server to PC, use -rz to upload.
Example: sz alvicr.com
2 Find the rule to clean up files
If you use manual cleaning, this step must be done carefully, after all, no one wants to clean up useful content.
Feel free to open an article with pictures, because I want to clean up the thumbnails generated in January of 2021.1, so I will open the articles published in the corresponding time period.
Take this article as an example : How to apply for Google Adsense for your website
(Https://alvincr.com/2021/01/%e5%a6%82%e4%bd%95%e7%bb%99%e4%bd%a0%e7%9a%84%e7%bd%91% e7%ab%99%e7%94%b3%e8%af%b7google-adsense/)
First enter the edit article interface, and select the text article.
You can see which picture is called by the picture with the img tag. For example, the picture called Google-Adsense-1 is called here, and the location is 2021/01. It is best to read the names of pictures used in several groups of articles here to avoid accidental deletion.
<img class=”alignnone wp-image-1074 size-full” src=”http://alvincr.com/wp-content/uploads/2021/01/Pasted-into-How to apply Google-Adsense- for your website 1.png” />
Enter the background through shell and other methods, and display all pictures with the name of Google-Adsense-1. It should be noted here that although the contents of these thumbnails are different at first glance, you will find that these large and small thumbnails are all captured from the source file when you open the picture.
For example: Pasted-into-how to apply for your website Google-Adsense-1-150×85 square looks and Pasted-into-how to apply for your website Google-Adsense-1-1024×62 completely unnecessary , But they are all generated by one file (Pasted-into-how to apply Google-Adsense-1 for your website).
So we got the pictures that we can delete, that is, Pasted-into-How to apply Google-Adsense-1 for your website and there are many files with suffixes, such as 75×75.
1 Cleaning method
Manual cleaning
1 Use win to clean up
Download the file, and then use the search function of win10 to directly clean it up.
Search for 75×75 like I did, then delete all
It can be seen that only a 75×75 thumbnail has a size of 4M (more than 700 files), which is evident in the storage space occupied by those HD pictures.
Finally, package the file, enter the rz command to upload the file, use the mv command to change the initial folder name, unzip the compressed package and rename it
2 Use the pagoda for cleaning
Before cleaning up, turn on the recycle bin function to temporarily save the deleted data. If you are not assured, you can not select the delete option, but move the files to other folders. If the website has no problems, it is not too late to delete. .
The method is the same as above, search for 75×75 (pay attention to check the include subdirectories), and then delete it.
3 Use linux commands to clean up
method one:
Use this method with caution, if it is written as rm -rf / then it is over. Noob, please read this article: linux anti-error deletion operation
, Although this code is very simple, but I am afraid that there is no such method.
rm -rf 75×75 (the code is no problem in theory)
Here * is used in Filename expansion to represent any character, including null characters.
/* means all files in the root directory.
Method Two:
Below is the result of my test using cat> 75×75-1 to generate a file and use the move file command instead of deleting the file
mkdir temp
mv 75×75 ./temp
Plugin cleanup
Personally, it is not very recommended to use plug-ins. Although it is very convenient, it is also prone to problems. The following are some of the more famous cleaning software:
DNUI
Media Cleaner
Force Regenerate Thumbnails
Personally tested WPvivid Image Cleaner (Beta)
Currently the software has a beta version to clean up pictures (2021.1.9)
Scan all pictures with Beta tab Scan
But deleting files is more troublesome. You can only select more than a dozen pictures each time, but it is detected that more than 3000 pictures need to be deleted, so it was finally abandoned.
2 review
1 Need to know
If you enable CDN acceleration, you need to suspend the CDN acceleration service (you can also enter the CDN acceleration server to enter the developer mode), or wait for a period of time to review.
2 method
After the above methods are cleaned up, you can recheck whether any missing thumbnails have not been deleted. If they exist, just add rules to delete them; if they don’t exist, check whether the access to each device is normal.
It is recommended to use the sorting method from largest to smallest for the review. It doesn’t matter if the image remains very small. Here all my thumbnails have “-number x”, so I only need to check this way. You can also use the win command “-*X” search, find something similar to 150×88 and delete it.
After the operation is completed, you can clearly see the folder size drop (600M->117M)