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

Videos don't have derivatives, serve them straight away. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions helper_funcs.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Copy link
Owner

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'

Copy link
Author

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 ;-) ).

Copy link
Owner

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

return $path;
}

if ($user['enabled_high']) {
return $path;
}
Expand Down