diff --git a/aq_resizer.php b/aq_resizer.php index 8521360..f40b7f6 100644 --- a/aq_resizer.php +++ b/aq_resizer.php @@ -125,7 +125,9 @@ public function process( $url, $width = null, $height = null, $crop = null, $sin } else { // Use this to check if cropped image already exists, so we can return that instead. $suffix = "{$dst_w}x{$dst_h}"; - $dst_rel_path = str_replace( '.' . $ext, '', $rel_path ); + // Only replace actual extension to prevent replacing extension string occurrence in filename + $ext_pos = strrpos( $rel_path, $ext ); + $dst_rel_path = substr_replace( $rel_path, '', $ext_pos - 1, strlen( $ext ) + 1 ); $destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}"; if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {