Skip to content

Commit

Permalink
Move to root
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdesign committed Jun 19, 2021
1 parent 0455b56 commit bb6c840
Show file tree
Hide file tree
Showing 41 changed files with 414 additions and 41 deletions.
File renamed without changes.
File renamed without changes
8 changes: 4 additions & 4 deletions packages/lib_juimage/composer.lock → composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes
31 changes: 11 additions & 20 deletions packages/lib_juimage/src/Image.php → src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ public function render($url, array $attr = [])

if(isset($attr[ 'webp' ]) === true)
{
$output = $this->thumb($url, array_merge($attr, [ 'f' => 'webp' ]));

return (object) [
'img' => $img,
'webp' => $output
'webp' => $this->thumb($url, array_merge($attr, [ 'f' => 'webp' ]))
];
}

Expand Down Expand Up @@ -87,11 +85,14 @@ public function size($img_path)
* @param array $attr
*
* @return object|string
* @return object|string
* @since 4.0
*/
private function thumb($url, array $attr = [])
{
$_error = false;
$img_name = implode($attr);
$img_url = 'cover';

if($url !== 'cover')
{
$url = trim($url, '/');
Expand Down Expand Up @@ -127,12 +128,6 @@ private function thumb($url, array $attr = [])
$img_url = preg_replace('#[а-яёєїіА-ЯЁЄЇІ]#iu', '', $img_url);
$img_url = str_replace([ ' +', ' ' ], [ '_', '' ], $img_url);
}
else
{
$_error = false;
$img_name = implode($attr);
$img_url = 'cover';
}

$file_ext = [];
$img_size = [];
Expand Down Expand Up @@ -209,7 +204,7 @@ private function thumb($url, array $attr = [])
$target = $subfolder . '/' . $img_url;
if(file_exists($this->path . '/' . $target))
{
$output = $target;
return $target;
}
else
{
Expand All @@ -219,10 +214,8 @@ private function thumb($url, array $attr = [])
$this->makeDir($path);
}

$output = $this->createThumb($url, $img_cache, $target, $attr);
return $this->createThumb($url, $img_cache, $target, $attr);
}

return $output;
}

/**
Expand Down Expand Up @@ -332,7 +325,7 @@ private function createThumb($url, $img_cache, $target, array $attr = [])
* @return bool|string
* @since 4.0
*/
private function createVideoThumb($url, $video_detect = false)
private function createVideoThumb($url, bool $video_detect = false)
{
$urls = parse_url($url);

Expand All @@ -344,7 +337,6 @@ private function createVideoThumb($url, $video_detect = false)
if($urls[ 'host' ] === 'youtu.be')
{
$id = ltrim($urls[ 'path' ], '/');

if(strpos($urls[ 'path' ], 'embed') == 1)
{
$cut_embed = explode('/', $urls[ 'path' ]);
Expand Down Expand Up @@ -427,14 +419,13 @@ private function vimeo($id)

/**
* @param $dir
* @param int $mode
*
* @return bool
* @since 4.0
*/
private function makeDir($dir, $mode = 0777)
private function makeDir($dir)
{
if(mkdir($dir, $mode, true) || is_dir($dir))
if(mkdir($dir, 0777, true) || is_dir($dir))
{
return true;
}
Expand All @@ -444,7 +435,7 @@ private function makeDir($dir, $mode = 0777)
return false;
}

return mkdir($dir, $mode, true);
return mkdir($dir, 0777, true);
}

/**
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public function RenderOutput() {
break;
}
$this->DebugMessage('GD does not have required built-in support for BMP output', __FILE__, __LINE__);
if (!@include_once __DIR__ .'/phpthumb.bmp.php' ) {
if (!@include_once __DIR__ . '/phpthumb.bmp.php') {
$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.bmp.php" which is required for BMP format output', __FILE__, __LINE__);
ob_end_clean();
return false;
Expand All @@ -575,7 +575,7 @@ public function RenderOutput() {
break;

case 'ico':
if (!@include_once __DIR__ .'/phpthumb.ico.php' ) {
if (!@include_once __DIR__ . '/phpthumb.ico.php') {
$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.ico.php" which is required for ICO format output', __FILE__, __LINE__);
ob_end_clean();
return false;
Expand Down Expand Up @@ -693,7 +693,7 @@ public function OutputThumbnail() {
imagebmp($this->gdimg_output);
break;
}
if (!@include_once __DIR__ .'/phpthumb.bmp.php' ) {
if (!@include_once __DIR__ . '/phpthumb.bmp.php') {
$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.bmp.php" which is required for BMP format output', __FILE__, __LINE__);
return false;
}
Expand All @@ -714,7 +714,7 @@ public function OutputThumbnail() {
break;

case 'ico':
if (!@include_once __DIR__ .'/phpthumb.ico.php' ) {
if (!@include_once __DIR__ . '/phpthumb.ico.php') {
$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.ico.php" which is required for ICO format output', __FILE__, __LINE__);
return false;
}
Expand Down Expand Up @@ -966,10 +966,10 @@ public function setOutputFormat() {

$AvailableImageOutputFormats = array();
$AvailableImageOutputFormats[] = 'text';
if (@is_readable( __DIR__ .'/phpthumb.ico.php')) {
if (@is_readable(__DIR__ . '/phpthumb.ico.php')) {
$AvailableImageOutputFormats[] = 'ico';
}
if (@is_readable( __DIR__ .'/phpthumb.bmp.php')) {
if (@is_readable(__DIR__ . '/phpthumb.bmp.php')) {
$AvailableImageOutputFormats[] = 'bmp';
}

Expand Down Expand Up @@ -2396,7 +2396,7 @@ public function Rotate() {
$this->DebugMessage('!function_exists(imagerotate)', __FILE__, __LINE__);
return false;
}
if (!include_once __DIR__ .'/phpthumb.filters.php' ) {
if (!include_once __DIR__ . '/phpthumb.filters.php') {
$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.filters.php" which is required for applying filters ('.implode(';', $this->fltr).')', __FILE__, __LINE__);
return false;
}
Expand Down Expand Up @@ -2594,7 +2594,7 @@ public function AntiOffsiteLinking() {
$this->config_nooffsitelink_watermark_src = $this->ResolveFilenameToAbsolute($this->config_nooffsitelink_watermark_src);
if (is_file($this->config_nooffsitelink_watermark_src)) {

if (!include_once __DIR__ .'/phpthumb.filters.php' ) {
if (!include_once __DIR__ . '/phpthumb.filters.php') {
$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.filters.php" which is required for applying watermark', __FILE__, __LINE__);
return false;
}
Expand Down Expand Up @@ -2734,7 +2734,7 @@ public function AlphaChannelFlatten() {

public function ApplyFilters() {
if ($this->fltr && is_array($this->fltr)) {
if (!include_once __DIR__ .'/phpthumb.filters.php' ) {
if (!include_once __DIR__ . '/phpthumb.filters.php') {
$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.filters.php" which is required for applying filters ('.implode(';', $this->fltr).')', __FILE__, __LINE__);
return false;
}
Expand Down Expand Up @@ -3113,7 +3113,7 @@ public function ApplyFilters() {
$threshold = ('' !== $threshold ? $threshold : 3);
if (phpthumb_functions::gd_version() >= 2.0) {
ob_start();
if (!@include_once __DIR__ .'/phpthumb.unsharp.php' ) {
if (!@include_once __DIR__ . '/phpthumb.unsharp.php') {
$include_error = ob_get_contents();
if ($include_error) {
$this->DebugMessage('include_once("'. __DIR__ .'/phpthumb.unsharp.php") generated message: "'.$include_error.'"', __FILE__, __LINE__);
Expand Down Expand Up @@ -3964,7 +3964,7 @@ public function SourceImageToGD() {
switch (@$this->getimagesizeinfo[2]) {
case 6:
ob_start();
if (!@include_once __DIR__ .'/phpthumb.bmp.php' ) {
if (!@include_once __DIR__ . '/phpthumb.bmp.php') {
ob_end_clean();
return $this->ErrorImage('include_once('. __DIR__ .'/phpthumb.bmp.php) failed');
}
Expand Down Expand Up @@ -4128,7 +4128,7 @@ public function phpThumbDebug($level='') {
$DebugOutput[] = 'PHP_OS = '.PHP_OS;
$DebugOutput[] = '$_SERVER[SERVER_SOFTWARE] = '.@$_SERVER['SERVER_SOFTWARE'];
$DebugOutput[] = '__FILE__ = '.__FILE__;
$DebugOutput[] = 'realpath(.) = '.@realpath('.');
$DebugOutput[] = 'realpath(.) = '.@realpath('');
$DebugOutput[] = '$_SERVER[PHP_SELF] = '.@$_SERVER['PHP_SELF'];
$DebugOutput[] = '$_SERVER[HOST_NAME] = '.@$_SERVER['HOST_NAME'];
$DebugOutput[] = '$_SERVER[HTTP_REFERER] = '.@$_SERVER['HTTP_REFERER'];
Expand Down Expand Up @@ -4407,7 +4407,7 @@ public function ImageCreateFromStringReplacement(&$RawImageData, $DieOnErrors=fa

// Need to create from GIF file, but imagecreatefromgif does not exist
ob_start();
if (!@include_once __DIR__ .'/phpthumb.gif.php' ) {
if (!@include_once __DIR__ . '/phpthumb.gif.php') {
$ErrorMessage = 'Failed to include required file "'. __DIR__ .'/phpthumb.gif.php" in '.__FILE__.' on line '.__LINE__;
$this->DebugMessage($ErrorMessage, __FILE__, __LINE__);
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public function unregister()
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
Expand All @@ -347,6 +347,8 @@ public function loadClass($class)

return true;
}

return null;
}

/**
Expand Down
Loading

0 comments on commit bb6c840

Please sign in to comment.