Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Prevent replacing string occurences of extension in filename #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion aq_resizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) ) {
Expand Down