-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix for issue #1277 #1279
Fix for issue #1277 #1279
Conversation
@nicolasbeauvais The CI failed because of some rules of coding standard 👍 |
Ping for notice: @freekmurze |
@nicolasbeauvais Thanks for this! 👍 Could you add a test to make sure that these changes work? |
WIP:
|
I should be done with this, of course, feel free to suggest any improvements. I will update the documentation once this gets merged! |
Thank you so much for your work on this 👍 |
@freekmurze Where is versioned the docs of the package? It's great to update it to include a section explaining this feature. I can help creating a PR for this 👍 |
@pedrofurtado https://docs.spatie.be/laravel-medialibrary/v7/introduction |
@nicolasbeauvais @pedrofurtado could you please add an example who to work with this feature? |
hi @pedrofurtado, can you confirm your hls conversion works with this update? i tried to make a similar conversion (mp4 -> hls) using your code as a start (#1277) i'm facing 2 issues:
Thanks |
did the two issues above regarding conversio nfile name and moving t ocorrect dir get resolved?
|
Hi all.
I had the first problem @jayenne , I solved it in the following way: $this->addMediaCollection('audio')->singleFile()
->registerMediaConversions(function (Media $media) {
$this->addMediaConversion('ogg')
//->withoutManipulations() #Removed for redundancy in this case.
->setManipulations(function (Manipulations &$manipulations){
$manipulations = new class extends Manipulations{
const FORMAT_OGG = 'ogg';
public function isEmpty(): bool
{
return true;
}
};
$manipulations->format('ogg');
})->nonQueued();
}); MyModel::first()->addMedia('path/to/file.wav')->toMediaCollection('audio'); MyModel::first()->getFirstMediaUrl('audio', 'ogg');
// http://localhost/storage/#/conversions/file-ogg.ogg <- Already change the extension I hope it will help someone in the future :) |
This PR make two changes:
Minor:
The
performConversion
method only perform manipulations has the conversion is made in theperformConversions
method on line 94.So it makes more sense to rename it
performManipulations
instead. It will also reduce confusion betweenperformConversions
andperformConversion
.Fix for issue #1277:
Problem:
Creating a custom generator that returns a file that is not an image (in that case a .m3u8 file) fail because manipulations are being automatically run on that file which is not compatible.
Proposed fix:
The end user needs to disable the default manipulations for the specific conversion like:
And in the core, we check if the running conversion has manipulation to be triggered, if not we skip this step and the converted file stay untouched.
I haven't dive in the core code for a long time so I might be missing something here, anyway do not hesitate to indicate any change that could be made to improve this fix.