PHP Classes
elePHPant
Icontem

File: examples/download_sprite_example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Arturs Sosins  >  CSS sprite class  >  examples/download_sprite_example.php  >  Download  
File: examples/download_sprite_example.php
Role: Example script
Content type: text/plain
Description: CSS sprite forcing download example
Class: CSS sprite class
Generate sprite images and CSS to use image styles
Author: By
Last change: credits changed
Date: 4 years ago
Size: 1,625 bytes
 

Contents

Class file image Download
<?php
/*************************************************************
 * This script is developed by Arturs Sosins aka ar2rsawseen, http://webcodingeasy.com
 * Fee free to distribute and modify code, but keep reference to its creator
 *
 * This class can generate CSS sprite image from multiple provided images
 * Generated image can be outputted to browser, saved to specified location, etc.
 * This class also generates CSS code for sprite image, using element ID's provided with image.
 * It facilitates CSS sprite implementations to existing website structures
 *
 * For more information, examples and online documentation visit:
 * http://webcodingeasy.com/PHP-classes/CSS-sprite-class-for-creating-sprite-image-and-CSS-code-generation
**************************************************************/

/*
 * This example shows how to save CSS sprite to specified location or force to download it
 */
 
//declaring class instance
include("../css_sprite.class.php");
$sprite = new spritify();

//adding test images
$sprite->add_image("../test_images/php.jpg", "jpeg");
$sprite->add_image("../test_images/php.gif", "gif");
$sprite->add_image("../test_images/elephpant.png", "elephant");

//retrieving error
$arr = $sprite->get_errors();
//if there are any then output them
if(!empty($arr))
{
    foreach(
$arr as $error)
    {
        echo
"<p>".$error."</p>";
    }
}
else
{
   
//saves file in provided path
    //in this example it is in the same folder with file name file.png
    //$sprite->safe_image("./file.png");
   
    //forces file download in browser window
   
$sprite->safe_image();
   
}
?>