There is a great website for WordPress called WP-Snippets. It has all kinds of very useful code bits to use in a WordPress site. This is just the kind of work for which ScriptManager was made. You can very easily incorporate these code snippets in ScriptManager that will make your site so much more productive and usable. After going through several and implementing them, you start to really get an overall understanding of WordPress.
In this tutorial, I am going to show you how to put this website to use with ScriptManager. We are going to take the article on removing compression from jpeg images that are saved in WordPress. The article is Keep WordPress from compressing jpgs. Please go to this website and read the article first.
Next, you notice that the code is really just one line of PHP code they say to put into your functions.php of your current theme. If you change themes, you need to migrate this over as well. But with ScriptManager, you never have to think about it again! Looking at the code, you see that it is just a custom filter for the ‘jpeg_quality’ filter. We can create this easily.
Create a new filter with the name ‘jpeg_quality’ and the arguments line with the variable $args. All filters should have at least one argument. This one actually has two arguments: quality of the jpeg, function to perform (usually an ‘image_resize’ tag). Since we do not care about these for this example, we just define one argument, ‘$args’. Your screen should look like this:
After you create the filter, select it and add the line below:
As soon as you save the script, every jpeg image saved will be saved at 100% quality. It is that simple. If you want to change the percentage, just change the 100 in the filter to whatever value you want. A filter is created as a function. The code you type in is the body of the function. Since we just want to return a default value, it is just a ‘return(100);’ to get the job done!
Any other code snippet found on WP-Snippets can be programmed in ScriptManager in a similar way. Just look for what action or filter is being defined and duplicate it with an action or filter in ScriptManager. Play around with others on the site and see what you can do!