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

File name does not depend of quality #9

Open
quentinneyraud opened this issue Mar 23, 2020 · 1 comment
Open

File name does not depend of quality #9

quentinneyraud opened this issue Mar 23, 2020 · 1 comment

Comments

@quentinneyraud
Copy link

Hello @getdave,

I'm trying to create a on-demand image resizing with Wordpress and your plugin helps me a lot 👍 .

I can access to URLs like this BASE_URL/app/uploads/2020/02/food-photographer-i-david-fedulov-X92WLoaQ1_o-unsplash.jpg/?width=500&quality=80 with different widths to generate and get different images but changing quality parameter always return the same image.

I think it is because quality parameter is never used in file name creation, so the cached version is returned.

Maybe it should be pushed to $args array here

private function set_cache_file_path() {
// Strip PHP callables out of the args
$args = $this->strip_callables( $this->intervention_args );
// Sort the array by key to ensure consistency of caching filename
ksort( $args );
$file_pathinfo = pathinfo( $this->src );
$ext = $file_pathinfo['extension'];
$new_filename = $file_pathinfo['filename'] . '-' . crc32( $this->r_implode( $args, '-' ) ) . '.' . $ext;
// Enable filtering of the filename on a per file basis
$new_filename = apply_filters( 'wpi_cache_file_name', $new_filename, $file_pathinfo['filename'], $ext, $args );
$this->cache_file_path = WP_Intervention::get_cache_dir() . $new_filename;
}

Someting like :

$args['quality'] = $this->options['quality'];

on line 135.

I can make a PR or add detailed code if you want more infos on my use case.

@getdave
Copy link
Owner

getdave commented Mar 27, 2020

It is great to see you found this useful. Thanks for letting me know and taking the time to raise this Issue.

Yes i see the problem. That is correct and an oversight on my part.

I would love to see a PR. It would help me a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants