\SSImageMin
Synopsis
class SSImageMin
{
- // members
- public static string $image_directory = '';
- public static string $increased_memory_limit = '2480M';
- public static integer $compress_rate = 85;
- public $image_src;
- public $is_remote;
- public $options;
- public $cached_image_directory;
- public $cached_filename;
- protected $gd_version;
- protected $memory_limit;
- protected $file_mime_type;
- protected $file_extension;
- protected $local_image_src;
- protected $src_filesize;
- protected $cached_filesize;
- // methods
- public static void get_cache_directory()
- public static void get_cached_image()
- public static void delete_cache_files()
- public __construct()
- public bool can_run_image_cache()
- protected void download_image()
- protected bool make_cache_directory()
- protected If fetch_image()
- protected string docroot_to_url()
- protected void pre_set_class_vars()
- protected bool link_is_broken()
- protected bool is_image_local()
- protected void set_is_remote()
- protected void set_cached_filename()
- protected void cached_file_exists()
- protected void set_file_mime_type()
- protected void set_memory_limit()
- protected void increase_memory_limit()
- protected void reset_memory_limit()
- protected void error()
Members
protected
-
$cached_filesize
The extension of the file -
$file_extension
The extension of the file -
$file_mime_type
The file mime type -
$gd_version
Stores the server's version of the GD Library, if enabled -
$local_image_src
The original size of the file -
$memory_limit
The memory limit currently established on the server -
$src_filesize
The original size of the file
public
-
$cached_filename
The name of the cached file -
$cached_image_directory
The location of the cached images directory - $compress_rate
- $image_directory
-
$image_src
Stores the image source given for reference - $increased_memory_limit
-
$is_remote
If the file is remote or not -
$options
Allow the user to set the options for the setup
Methods
protected
- cached_file_exists() — Simply determines if a compressed of the image that's sent is already compressed or not.
- docroot_to_url() — Returns
- download_image() — Downloads a remote file and stores it locally to be used for compression
- error() — Displays an error and kills the script
- fetch_image() — Fetch the image as a resource and save it into the cache directory.
- increase_memory_limit() — Temporarily increases the servers memory limit to 2480 MB to handle building larger images. Based on initial tests, this seems to be a large enough increase to handle rebuilding jpg images as large as 4300px wide with no pre-compression.
- is_image_local() — Quick and dirty way to see if the file is remote or local. Deeper checking comes later if we don't find a compressed version of the file locally.
- link_is_broken() — Utility function to determine of the link in question is broken or not.
- make_cache_directory() — Creates the cached directory
- pre_set_class_vars() — Sets up all class variables in one central function.
- reset_memory_limit() — Resets the servers memory limit to its original value
- set_cached_filename() — This function creates the filename of the new image using an MD5 hash of the original filename. This helps to create a unique filename for the newly compressed image so that this class can easily find and determine if the image has already been compressed and stored locally.
- set_file_mime_type() — Stores the file's mime type and validates that the file being compressed is indeed an image.
- set_is_remote() — Determines if the image is local or being referenced from a remote URL
- set_memory_limit() — Stores the original value of the server's memory limit
public
- __construct() — Constructor function
- can_run_image_cache() — Validates whether the user can use this class or not, based on the GD Version their server is carrying.
- delete_cache_files()
- get_cache_directory()
- get_cached_image()