Skip to content

Commit

Permalink
1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
conseilgouz committed Aug 7, 2024
1 parent 9ccaedb commit fc828fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Extension/Cgwebp.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @version 1.2.2
* @version 1.2.5
* @package CGWebp system plugin
* @author ConseilGouz
* @copyright Copyright (C) 2024 ConseilGouz. All rights reserved.
Expand Down Expand Up @@ -112,7 +112,7 @@ function ($match) use ($quality, $stored_time, $excludedArr, &$debugTarget, $reg
$debugTarget[] = array(
'source' => $image,
'target' => $newImg,
'new' => false
'new' => 'false'
);
}
return $newImg ? $newImg : $img;
Expand Down Expand Up @@ -155,7 +155,7 @@ private function imgToWebp($image, $quality = 100, $excluded = array(), $stored_
$imgPath = JPATH_ROOT . '/' . $image;
$imgInfo = pathinfo($imgPath);
$imgHash = md5($imgPath);
$bNew = false;
$bNew = 'false';

if(!isset($imgInfo['extension']) || !$imgInfo['extension']) {
return;
Expand Down Expand Up @@ -204,7 +204,7 @@ private function imgToWebp($image, $quality = 100, $excluded = array(), $stored_
imagealphablending($img, true);
imagesavealpha($img, true);
imagewebp($img, $newImage, $quality);
$bNew = true;
$bNew = 'true';
} catch (\Throwable $throwable) {
return false; // conversion error :ignore image
}
Expand Down
6 changes: 3 additions & 3 deletions src/Helper/CgwebpHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public static function browserSupportWebp() {
$user_agent = $_SERVER['HTTP_USER_AGENT'];

// If browser is Internet Explorer
if (strpos(user_agent, 'MSIE') !== false) return false;
if (strpos($user_agent, 'MSIE') !== false) return false;

// If user browser is safari and is not Opera
if(
strpos($user_agent, 'Safari') &&
!strpos( $user_agent, ' Chrome/' ) &&
!strpos($user_agent, ' Chrome/' ) &&
!(strpos($user_agent, 'Edge'))
) return false;

Expand All @@ -36,7 +36,7 @@ public static function browserSupportWebp() {

// If browser doesnt support webp
if (isset($_SERVER['HTTP_ACCEPT'])) {
if (!strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' )) {
if (!strpos($_SERVER['HTTP_ACCEPT'], 'image/webp' )) {
return false;
}
}
Expand Down

0 comments on commit fc828fe

Please sign in to comment.