Compressing all images iszes without plugin
-
Hi,
I would like to compress all image sizes created by WP and other plugins/themes without plugin, before uploading. When I compress the just the actual image I am uploading, obviously none of the thumbnails are compressed.
Thanks!
-
Go for it! Since you want it to happen before upload, a plugin couldn’t help you anyway.
My question is: how? WordPress does not recognize images when I upload them not through the media library but via FTP.
Are you trying to fix the ones already uploaded? There are plugins for that.
Are you trying to process images before uploading? That’s outside of WordPress, so you can use any tool you want, although there is at least one plugin for that.https://wordpress.org/support/topic/broken-links-after-migration-from-wordpress-com/#post-11556577
create a backup of your files, your backup of your database, export your xml file.
Work (compress) your images without changing names.
occasionally install autoptimize plugin which removes unused thumbnails or after the first time you use this plugin add the constant to wp_confing.php https://wordpress.org/support/article/editing-wp-config-php/#cleanup-image-editsjust to make clear; autoptimize does _not_ remove unused thumbnails, guess you’re thinking of another plugin there @autotutorial 🙂
enjoy the weekend,
frank (ao dev)Yes my mistake here
This a guide with the use of two plugins to delete and regenerate thumbnails https://www.pixemweb.com/blog/clean-old-wordpress-thumbnails/ thank @optimizingmatters for your fix, good weekend to you too. 🙂Hi,
thanks for your answers but my problem is the following: I am creating a NEW site, and I don’t want to use any plugins, for performance reeasons. That’s why I don’t want to use Smush or Eww or Short Pixel etc. But obviously I still want all my mages compressed, including all the sizes that are created by WP upon uploading images. So simply just compressing the main image before uploading does not change/compress all the other sizes created. And if I manually create these additional sizes and compres them beforehand, and then upload everything via FTP, thery are not registered in the media library. I know there are plugins to register them, but that would defeat the purpose since I don’t want to use plugins.It is not possible to use the image library in any other way than by loading through it or exporting now without changing the name or without changing the theme you can try a directly compress the thumbnail in the upload folder, now it importing with the plugin proposed in the first link.
Note* WordPress create file xml with object serialized, I’m not sure if you need to change anything in the string object of the xml file before exporting.Given that the site is new, what problems do you encounter in uploading images that are already compressed?
Wordpress by default keeps the original and modified files. If you change the theme (or use specific plugins) other thumbnails will be created.Hi,
I am not encountering any problems zploading images other then that the other sizes that are automatically created by WP are NOT optimized. That’s why plugin such as Smush or Ewww exist – they compress ALL sizes that WP creates upon uploading. But I would like to avoid plugins.You need to validate your files in the media library, this means using php code or plugins to be recognized by the media library.
In the first link of this post I show you a plugin that does the trick. https://wordpress.org/support/topic/compressing-all-images-iszes-without-plugin/#post-11661410
You have to export, after your export you can compress the images of the upload folder without changing the name and height or width. Finally with the active plugin you can import your xml file.I am not encountering any problems zploading images other then that the other sizes that are automatically created by WP are NOT optimized.
That can’t be true. WP works off of the image it is given. It doesn’t create bigger sizes than the original. It uses a constant for the image quality percentage, which can be filtered.
That’s why plugin such as Smush or Ewww exist – they compress ALL sizes that WP creates upon uploading. But I would like to avoid plugins.
These plugins are mostly for people that didn’t realize their images were so large when they uploaded them.
Saying you want the code to behave differently than it does, but you don’t want plugins means that it can’t happen. If you want to add code, it has to go somewhere, and that is a plugin. If you change core files, the changes would be overwritten on the next update. And we don’t support modified versions here since we don’t know what you changed.
There’s nothing wrong with using plugins if the plugin is well-behaved. The ones in the WP repository have to follow guidelines and are reviewed before being allowed in.
Don’t be scared of a little code, especially if it only runs when you are uploading a file.WP works off of the image it is given. It doesn’t create bigger sizes than the original.
Of course the other sizes are not larger, but they are not compressed/optimized either. That’s what these plugins do. So I guess the only workaround would be to upload a compressed image through the media library and let WP generate all the other sizes, then download these other sizes via FTP, compress them and upload the new compressed sizes and replacing them via FTP.
Or just filter the compression percentage.
The topic ‘Compressing all images iszes without plugin’ is closed to new replies.