golden hour
/home/godaofbq/zenhealingstore.com/wp-content/plugins/2performant-import
⬆️ Go Up
Upload
File/Folder
Size
Actions
assets
-
Del
OK
build
-
Del
OK
changelog.txt
75 B
Del
OK
icon.png
2.06 KB
Del
OK
imageCORSFallback.class.php
2.59 KB
Del
OK
index.php
11.87 KB
Del
OK
woo-product.php
12.54 KB
Del
OK
Edit: imageCORSFallback.class.php
<?php class AA_2Performant_fallbackImageCORS { private $img_src = ''; private $img = ''; private $cfg = array(); private $maxWidth = 0; private $maxHeight = 0; private $imageHeaderStatus = false; function __construct() { $this->cfg['print_msg'] = array( 'font_size' => 5, 'padding' => 20, 'font_color' => '198,40,40', 'background_color' => '224,224,224' ); } public function setImage( $newImageSrc='' ) { if( trim($newImageSrc) == "" ){ $this->error_as_msg( "Image url is empty!" ); } $headers = get_headers( $newImageSrc ); if( isset($headers[0]) ) $this->imageHeaderStatus = $headers[0]; if( isset($headers[0]) && strpos($headers[0], '404') ) { $this->cfg['print_msg']['background_color'] = '229,57,53'; $this->cfg['print_msg']['font_color'] = '255,255,255'; $this->error_as_msg( 'Image Not Found!' ); } if( isset($headers[0]) && strpos($headers[0], '500') ) { $this->cfg['print_msg']['background_color'] = '229,57,53'; $this->cfg['print_msg']['font_color'] = '255,255,255'; $this->error_as_msg( '500 Internal Server Error!' ); } $this->img_src = $newImageSrc; if( isset($headers[0]) && strpos($headers[0], '200 OK') ) { $this->get_image(); } } public function maxSize( $width=50, $height=50 ) { $this->maxWidth = $width; $this->maxHeight = $height; } private function get_image() { $input = file_get_contents( $this->img_src ); $this->img = imagecreatefromstring( $input ); } private function error_as_msg( $msg='' ) { $width = imagefontwidth( $this->cfg['print_msg']['font_size'] ) * strlen( $msg ); $height = imagefontheight( $this->cfg['print_msg']['font_size'] ); $this->img = imagecreatetruecolor( $width + ( $this->cfg['print_msg']['padding'] * 2 ), $height + ( $this->cfg['print_msg']['padding'] * 2 ) ); $bk_color = explode( ",", $this->cfg['print_msg']['background_color'] ); imagefill( $this->img, 0, 0, imagecolorallocate( $this->img, $bk_color[0], $bk_color[1], $bk_color[2] ) ); $t_color = explode( ",", $this->cfg['print_msg']['font_color'] ); $text_color = imagecolorallocate( $this->img, $t_color[0], $t_color[1], $t_color[2] ); imagestring( $this->img, $this->cfg['print_msg']['font_size'], $this->cfg['print_msg']['padding'], $this->cfg['print_msg']['padding'], $msg, $text_color ); } public function print_image() { // Set the content type header - in this case image/jpeg header('Content-Type: image/jpeg'); // Output the image imagejpeg( $this->img ); // Free up memory imagedestroy( $this->img ); } }
Save