Current Path : /storage/v11800/acejewellery/public_html/wp-content/plugins/goal-framework/classes/ |
Linux v11800 5.3.0-1023-aws #25~18.04.1-Ubuntu SMP Fri Jun 5 15:19:18 UTC 2020 aarch64
|
Current File : /storage/v11800/acejewellery/public_html/wp-content/plugins/goal-framework/classes/createplaceholder.php |
<?php
/**
* Create placeholder
*
* @package goal-framework
* @author Team Goalthemes <goaltheme@gmail.com >
* @license GNU General Public License, version 3
* @copyright 2015-2016 Goal Themer
*/
class Goal_Create_Placeholder {
public static function create($size = array()) {
if (!empty($size)) {
$img_path = get_template_directory() . '/images/placeholder/' . $size[0] . 'x' . $size[1] . '.png';
if ( !file_exists($img_path) && $size[0] && $size[1] ) {
self::create_image( $size[0], $size[1], 'DDDDDD', $img_path );
}
return get_template_directory_uri() . '/images/placeholder/' . $size[0] . 'x' . $size[1] . '.png';
}
return '';
}
public static function create_image($width, $height, $bg_color, $folder )
{
//Define the text to show
$text = "$width X $height";
//Create the image resource
$image = ImageCreate($width, $height);
//We are making two colors one for BackGround and one for ForGround
$bg_color = ImageColorAllocate($image, base_convert(substr($bg_color, 0, 2), 16, 10),
base_convert(substr($bg_color, 2, 2), 16, 10),
base_convert(substr($bg_color, 4, 2), 16, 10));
//Fill the background color
ImageFill($image, 0, 0, $bg_color);
//Tell the browser what kind of file is come in
// header("Content-Type: image/png");
if( preg_match("#.png#", $folder)){
//Output the newly created image in png format
imagepng($image, $folder );
}
if( preg_match("#.jpg#", $folder)){
//Output the newly created image in png format
imagejpeg($image, $folder );
}
//Free up resources
ImageDestroy($image);
}
}