/library/UrlTube/Thumb.php
PHP | 71 lines | 57 code | 13 blank | 1 comment | 11 complexity | 894b1583c34c023a98a42d4aef982fbe MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT
- <?php
- class UrlTube_Thumb
- {
- public $srcWidth = 0;
- public $srcHeight = 0;
- public $destWidth = 0;
- public $destHeight = 0;
-
- public function getThumbPath( $type, $url )
- {
- }
-
- public function getThumb( $type, $url )
- {
- global $_SITE;
- if ( ! empty( $url['url'] ) )
- switch ( $type )
- {
- default:
- if ( defined( '__DEBUG__' ) && __DEBUG__ ) var_dump( 'SCAN ENDED WITH FATAL ERROR, NO TYPE SPECIFIED' );
- return -2;
- break;
-
- case 'image':
- $thumbPath = $_SITE['config']['fs']['path_public'] . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'thumbnails' . DIRECTORY_SEPARATOR . md5( $url['id_url'] ) . '.jpg';
- //var_dump( $thumbPath );
- if ( $url['image'] == 'N' || ! file_exists( $thumbPath ) )
- {
- if ( __DEBUG__ )
- var_dump( 'CReATING THUMB' );
-
- $t1 = new ImageBatchTransformation();
- $t1->source = $url['url'];
- $t1->destination = $thumbPath;
- $t1->maxWidth = 250;
- $t1->maxHeight = 200;
- $t1->format = TI_JPEG;
- $t1->jpegQuality = 95;
- $t1->interlace = true;
- $t1->replaceExisted = false;
- $t1->label['text'] = date('y') . ' (c) ' . $_SITE['config']['handler']->redirect->domain;
- $t1->label['vertPos'] = TI_POS_BOTTOM;
- $t1->label['horzPos'] = TI_POS_RIGHT;
- $t1->label['font'] = $_SITE['config']['fs']['path_public'] . DIRECTORY_SEPARATOR . 'FREESCPT.TTF';
- $t1->label['size'] = 10;
- $t1->label['color'] = '#ffff00';
- $t1->label['angle'] = 0;
- $t1->label['rotateAngle'] = 0;
- $t1->label['rotateBgColor'] = '#ffffff';
-
- $ibp = new ImageBatchProcessor();
-
- $n = $ibp->processEx(array($t1));
-
- $this->srcHeight = $imageHeight;
- $this->srcWidth = $imageWidth;
-
- if ( __DEBUG__ )
- var_dump("FINISHED");
- } else return FALSE;
-
- return TRUE;
- break;
- }
- else return FALSE;
- }
- }