diff --git a/ajax/showcomic.php b/ajax/showcomic.php index 9db4fa9..992567d 100644 --- a/ajax/showcomic.php +++ b/ajax/showcomic.php @@ -44,8 +44,9 @@ if ( $ext == "cbz" ) { $opened = $zip->open($comicfull); for ( $i=0; $i<$zip->numFiles; $i++ ) { $imgname = basename($zip->getNameIndex($i)); - $myext = substr($imgname, -3); - if ( ($myext == "jpg") || ($myext == "png") ) { + //$myext = substr($imgname, -3); + $myext = strtolower(pathinfo($imgname)['extension']); + if ( ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) { $imgname = str_replace("#", "", $imgname); $imgcontents = $zip->getFromIndex($i); $written = file_put_contents($comicoutputfull . $imgname, $imgcontents); @@ -58,8 +59,9 @@ if ( $ext == "cbz" ) { while ( false !== ($file = readdir($fh)) ) { $myfile = $comicoutputfull . $file; $mynewfile = $comicoutputfull . str_replace("#", "", $file); - $myext = strtolower(substr($file, -3)); - if ( ($myext == "jpg") || ($myext == "png") ) { + //$myext = strtolower(substr($file, -3)); + $myext = strtolower(pathinfo($imgname)['extension']); + if ( ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) { rename($myfile, $mynewfile); $files[] = basename($mynewfile); } diff --git a/functions.php b/functions.php index 3f08d20..b0eb92e 100644 --- a/functions.php +++ b/functions.php @@ -45,9 +45,11 @@ function makeThumb($item = "") { $imgdata = null; for ( $i=0; $i<$zip->numFiles; $i++ ) { $imgname = basename($zip->getNameIndex($i)); + $imgext = strtolower(pathinfo($imgname)['extension']); if ( (strcmp($lowest, $imgname) > 0) - && ((strcasecmp(substr($imgname, -3), "jpg") == 0) - || (strcasecmp(substr($imgname, -3), "png") == 0)) ) { + && ((strcasecmp($imgext, "jpg") == 0) + || (strcasecmp($imgext, "png") == 0) + || (strcasecmp($imgext, "webp") == 0)) ) { $lowest = $imgname; $imgdata = $zip->getFromIndex($i); } @@ -63,11 +65,12 @@ function makeThumb($item = "") { $lowest = "~"; foreach ( $entries as $entry ) { $imgname = $entry->getName(); + $imgext = strtolower(pathinfo($imgname)['extension']); if ( (strcmp($lowest, $imgname) > 0) - && ((strcasecmp(substr($imgname, -3), "jpg") == 0) - || (strcasecmp(substr($imgname, -3), "png") == 0)) ) { + && ((strcasecmp($imgext, "jpg") == 0) + || (strcasecmp($imgext, "png") == 0) + || (strcasecmp($imgext, "webp") == 0)) ) { $lowest = $imgname; - $ext = strtolower(substr($imgname, -3)); $didwrite = $entry->extract(false, $outfile); if ( !$didwrite ) { return false; } }