Image Store: Adding additional color options part 1

One of the benefits of using the Image Store plugin is that it provides hooks — base on the WordPress API — that allow you to modify the functionally without having to write the a whole new plugin or miss out on important updates.

Today I am going to show how to add additional color options for your images. This is very useful if you offert your clients other color options besides sepia and black and white.

Just remember that these filters for preview purposes only and do not give you the full color range that a photo-editor software can give you.

The image filter

The first stept on our tutorial is to add the following code to our theme’s functions.php file. Modify the imagefilter parameters as needed to achieve the desired color. To add additional colors add more “case” statements to the switch function.

function additional_color_effects( $image ){
	if( empty( $_REQUEST['c'] )  )
		return;

	//note: 's' = sepia; 'g'= B&W
	switch( $_REQUEST['c'] ){
		case 'gn':
			imagefilter( $image, IMG_FILTER_CONTRAST, -5 );
			imagefilter( $image, IMG_FILTER_COLORIZE, 93, 111, 38, 80 );
			break;
		default:
	}
} add_action( 'ims_apply_color_filter', 'additional_color_effects' );

We are passing the color option in our links using the GET method ( query string ) and using the letter “c” as our key. Your links will look samething like this: domain.com/pathtoimstore/image.php/?i=SecretKey&c=gn.

Note: if you want to try this tutorial on your site, and you are using Image Store v3.0.8 or an older version, you will have to remove code define( 'SHORTINIT', true ); from the image.php file inside the Image Store plugin.

What is next?

In our next post we’ll integrate our code with the “slideshow” page to allow the user to preview the image filters and allow them to make the right selection when purchasing an image.

One Comment on “Image Store: Adding additional color options part 1

Comments are closed.