Method | Description | |
---|---|---|
_delete_generated_if_image ( integer $post_id ) | Checks if attachment is an image before deleting generated files | |
add_filters ( ) : void | adds a 'relative' key to wp_upload_dir() result. | |
delete_generated_files ( string $local_file ) | Deletes the auto-generated files for resize and letterboxing created by Timber | |
get_letterbox_file_path ( $url, $w, $h, $color ) | ||
get_letterbox_file_url ( $url, $w, $h, $color ) | ||
get_resize_file_path ( $url, $w, $h, $crop ) | ||
get_resize_file_url ( $url, $w, $h, $crop ) | ||
get_server_location ( string $url ) : string | Determines the filepath corresponding to a given URL | |
get_sideloaded_file_loc ( string $file ) : string | Determines the filepath where a given external file will be stored. | |
img_to_jpg ( string $src, string $bghex = '#FFFFFF', $force = false ) : string | Generates a new image by converting the source GIF or PNG into JPG | |
init ( ) | ||
is_animated_gif ( string $file ) : boolean | checks to see if the given file is an aimated gif | |
letterbox ( string $src, integer $w, integer $h, string $color = '#000000', boolean $force = false ) : string | Generate a new image with the specified dimensions. | |
resize ( string $src, integer | string $w, integer $h, string $crop = 'default', boolean $force = false ) : string | Generates a new image with the specified dimensions. | |
retina_resize ( string $src, float $multiplier = 2, boolean $force = false ) : string | Generates a new image with increased size, for display on Retina screens. | |
sideload_image ( string $file ) : string | downloads an external image to the server and stores it on the server |
Method | Description | |
---|---|---|
add_actions ( ) | Deletes all resized versions of an image when the source is deleted or its meta data is regenerated | |
add_constants ( ) | Adds a constant defining the path to the content directory relative to the site for example /wp-content or /content | |
process_delete_generated_files ( string $filename, string $ext, string $dir, string $search_pattern, string $match_pattern = null ) | Deletes resized versions of the supplied file name. |
Method | Description | |
---|---|---|
_get_file_path ( integer $base, string $subdir, string $filename ) : string | Builds the absolute file system location of a file based on its different components | |
_get_file_url ( integer $base, string $subdir, string $filename, boolean $absolute ) : string | Builds the public URL of a file based on its different components | |
_operate ( string $src, object $op, boolean $force = false ) : string | Main method that applies operation to src image: 1. break down supplied URL into components 2. use components to determine result file and URL 3. check if a result file already exists 4. otherwise, delegate to supplied TimberImageOperation | |
analyze_url ( string $url ) : array | Takes in an URL and breaks it into components, that will then be used in the different steps of image processing. | |
find_wp_dimensions ( string $size ) : false | array | Find the sizes of an image based on a defined image size |
public static _delete_generated_if_image ( integer $post_id ) | ||
$post_id | integer | an attachment post id |
protected static add_actions ( ) |
protected static add_constants ( ) |
static public add_filters ( ) : void | ||
return | void |
static public delete_generated_files ( string $local_file ) | ||
$local_file | string | ex: /var/www/wp-content/uploads/2015/my-pic.jpg or: http://example.org/wp-content/uploads/2015/my-pic.jpg |
public static get_letterbox_file_path ( $url, $w, $h, $color ) |
public static get_letterbox_file_url ( $url, $w, $h, $color ) |
public static get_resize_file_path ( $url, $w, $h, $crop ) |
public static get_resize_file_url ( $url, $w, $h, $crop ) |
public static get_server_location ( string $url ) : string | ||
$url | string | |
return | string |
public static get_sideloaded_file_loc ( string $file ) : string | ||
$file | string | |
return | string |
public static is_animated_gif ( string $file ) : boolean | ||
$file | string | local filepath to a file, not a URL |
return | boolean | true if it's an animated gif, false if not |
protected static process_delete_generated_files ( string $filename, string $ext, string $dir, string $search_pattern, string $match_pattern = null ) | ||
$filename | string | ex: my-pic |
$ext | string | ex: jpg |
$dir | string | var/www/wp-content/uploads/2015/ |
$search_pattern | string | pattern of files to pluck from |
$match_pattern | string | pattern of files to go forth and delete |
public static resize ( string $src, integer | string $w, integer $h, string $crop = 'default', boolean $force = false ) : string | ||
$src | string | an URL (absolute or relative) to the original image |
$w | integer | string | target width(int) or WordPress image size (WP-set or user-defined). |
$h | integer | target height (ignored if $w is WP image size). If not set, will ignore and resize based on $w only. |
$crop | string | your choices are 'default', 'center', 'top', 'bottom', 'left', 'right' |
$force | boolean | |
return | string | (ex: ) |
public static sideload_image ( string $file ) : string | ||
$file | string | the URL to the original file |
return | string | the URL to the downloaded file |