-
Notifications
You must be signed in to change notification settings - Fork 7
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
Videos don't have derivatives, serve them straight away. #9
base: master
Are you sure you want to change the base?
Conversation
I can see your point. Please not that you have a bug in the test which will actually cause it to skip any file unless it starts with '.mp4' which is definitely not what we want. |
@@ -210,6 +210,11 @@ function pwg_privacy_verify_access ($img_id, $req_path) { | |||
|
|||
//file is original uploaded image | |||
if ( strpos($req_path, $path) === 0 ) { | |||
//file is a video, serve it. | |||
if ( strpos($path, '.mp4') !== 0 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strpos returns false
if it can't find the needle in the haystack.
0 is returned only if it is the first match like '.mp4file'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack. Let me rework the condition (this would be like the second time in my life I do PHP ;-) ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice that piwigo provides a get_extension
method (used couple of times in this file).
So you can probably just do get_extension($path) === 'mp4'
.
With multiple valid extensions you'll probably need to use in_array
to see if the extension is a valid one
Thanks for the comments. I like the idea of having that setting to control the extensions that have no derivatives generated. I will rework this code then. |
This PR allows to serve directly the videos instead of trying to create derivates. They would fail to serve videos, since yo don't need either the full resolution permission or a derivative.