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

Conversion file names #1636

Closed
aleksandertabor opened this issue Nov 21, 2019 · 3 comments
Closed

Conversion file names #1636

aleksandertabor opened this issue Nov 21, 2019 · 3 comments

Comments

@aleksandertabor
Copy link

aleksandertabor commented Nov 21, 2019

Currently after conversion names are generated with this scheme:

public function getConversionFile(string $file): string
    {
        $fileName = pathinfo($file, PATHINFO_FILENAME);
        $fileExtension = pathinfo($file, PATHINFO_EXTENSION);
        $extension = $this->getResultExtension($fileExtension) ?: $fileExtension;
        return "{$fileName}-{$this->getName()}.{$extension}";
    }

source:
https://github.com/spatie/laravel-medialibrary/blob/master/src/Conversion/Conversion.php

where getName() is conversion name like 'thumb'.
output is: originalName-thumb.jpg

Question: Is it possible to get custom file names for conversions without name inside or use subfolders for each conversion and keep the original name of file? Maybe is it possible to create inferface similar to PathGenerator for setting up: https://docs.spatie.be/laravel-medialibrary/v7/advanced-usage/using-a-custom-directory-structure/#using-a-custom-directory-structure ?

example:
1/conversions/thumb/originalName.jpg
1/conversions/thumb/originalName.webp
1/conversions/desktop/originalName.jpg
1/conversions/desktop/originalName.webp

@hubertnnn
Copy link

I think #1686 is related to this as well.

One case that I would add is that we might want to secure some of the files.
I had a project where thumbs were supposed to be available for free but HD versions of image were sold, so different and secure paths were important.

Having a way to fully customize paths to conversions (including disk, path and filename) would be helpful.

@freekmurze
Copy link
Member

I'll take a look at this when creating a new major version of the package.

@freekmurze
Copy link
Member

Conversion file namers have been implemented in v8

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

3 participants