I need to replace all non-square pictures of a WordPress WooCommerce shop by square versions for design reasons.
To do so I follow these asghhgfdsasdfghj steps:
Download all images using an ftp-client.
The pictures are located in a folder as follows:
You will find them in a folder structure of years and months. Simply Download the all years folders from the uploads folder and save them to a dedicated folder (to_edit e.g.).
Get rid of all preview versions.
WordPress adds previews named as follows to the original version:
You will find quite a lot of different sizes.
Use your command line (Terminal on Mac OS systems e.g.) and go to the folder you put all the years folder in using commands as follows:
To list your directory’s content use
To enter a subfolder use
Or simply enter the whole path to your target folder if you already know it, like
Delete all previews in all subfolders using this command:
find . -name \*150x150* -type f -delete
- You need to replace the 150×150 with the sizes of your previews given.
- -type f searches for files only
- -delete will delete the files found – if you want to check first, what will be deleted, run the command without the -delete to get a list
Repeat this with other resolutions you’d like to delete until you have no more left then your original image files.
Replace all non-square images by their square versions.
You do this using this command:
Upload the new versions in the exact order of the original file system.
As you made sure in the step before, all images still have the same name like their non-square predecessors and are still stored on the very same place in the file system as before you simply upload and replace all year folders in the upload folder on your webspace.
Rebuild all previews
You can easily do so using a WP plugin like AJAX Thumbnail Rebuild.
Just install it and find it in tools section to run it.
Ressources I used to learn this: