Skip to content

File name does not depend of qualityΒ #9

@quentinneyraud

Description

@quentinneyraud

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions