Back to main index

Callback Routines

Saving Images to Your Server

You will need to create your own callback routine to save the optimized images to your server.

Specify the URL of your callback routine using API parameter uplink_url.

(sample callback routines are available here)

Example

The following code will open fred.jpg in webresizer for editing with the link 'Add to My Gallery' showing. Once the user has finished editing the image, control is passed to your callback routine 'transfer.php'. Your callback routine will need to perform validations and save the optimized image to your server.

<script type="text/javascript">
 
var webresizerAPI = new Object;
webresizerAPI.parameters = {
	apikey : 'your API Key here',
	image_url : 'http://www.example.com/fred.jpg',
	is_sample_image : 'no',
	uplink_text : 'Add to My Gallery',
	uplink_url : 'http://www.example.com/gallery/transfer.php'
};

</script>
<script type="text/javascript"
src="http://api.webresizer.com/ext1.0/js/webresizer_api.js"></script>

GET parameters

The following information is available to your callback routine as GET parameters appended to the uplink_url.

urlthe location of the optimized image
valid values:URL
filename the name of the optimized image
valid values:filename
filesizethe size of the optimized image in kilobytes
valid values:numeric
filetypethe type of the optimized image
valid values:jpg, gif, png
heightthe height in pixels of the optimized image
valid values:numeric
widththe width in pixels of the optimized image
valid values: numeric

For example, before saving the image to your servers you can check that the image size meets your requirements by checking the 'filesize' value returned. If the image is not the correct size, your callback routine can simply re-open the image in Web Resizer and display a suitable message to the user.

More Advanced Features

Session Variables - using session variables with the API