Automate Image Optimization for WordPress Without the Exec() Command

A lot of times, in shared hosting environments, the ability for PHP scripts to run the exec() command is disabled for security reasons. This command allows PHP programs to run shell commands on the server, which can be harmful. It’s easier to just not allow it for the majority of shared hosting providers. Generally, switching to a VPS, albeit more work and technical know how on the webmasters’ (or webmistress’) part, allows for that command to be used.

However, for most WordPress users, it is my guess, that managing their own server isn’t in the job description. And, they could be up and running with a WordPress site, from domain name purchase to “Hello World”, in 10 minutes easy and not know a lick about the server. So why fuss with a server just for the ability to run the exec() command in PHP? I’m sure there are reasons, but if it’s just to keep using your favorite image optimization plugin for WordPress, perhaps it’s time to have a look at a cloud-optimization solution instead.

img-optimize

What is Cloud Image Optimization?

“In the cloud” is one of those terms that gets annoying after awhile. I thought it was very cool and descriptive when my nerdy networking mentor described the hospital network that way when I landed my first IT job out of college. But now, it’s old hat. However, I still do secretly think it’s kinda cool. Shhh.

In terms of image optimization in the cloud, the process goes something like this:

a) you upload an image to the Media Library in WordPress
b) the “in-the-cloud” WordPress plugin pulls the image securely to a remote server
c) the server has it’s way with it, running all the shell commands it desires (these folks are smart cookies)
d) they send the optimized image back to your WordPress media library

Those steps are generally done silently in the background, and the servers have to “handshake” probably by way of an API, but you get the idea. The processing or optimization is done in the cloud… i.e. not locally on the machine where your web site is.

Keeping Backups of the Images

What made me initially uncomfortable about automated image processing is the loss of the original image just in case something goes awry. Try uploading a comic image with a “lossy” setting and panic might ensue for you as well.

But not to worry, most of the better made image tweaking plugins for WordPress, will backup your images before optimizing. And this one here makes it really simple to revert back to the original. Just head to the media library (in list view) and below the ShortPixel Compression heading you will see a “Restore backup” button, assuming backups are turned on, which they will be by default.

But, eventually, you might want to turn off backups. Because, besides reducing bandwidth, and increasing user retention, we want our image optimization efforts to save on storage space as well. As these are the commodities of the Web after all.

Mars Cureg

Web designer by profession, photography hobbyist, T-shirt lover, design blog founder, gamer. Socially and physically awkward, lack of social skills, struggles to communicate with anyone who doesn't have a keyboard. Willing to walk to get to the promised land. Photo and video freelancer, SEO. Check out more on my Google+

You may also like...