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

Photo.php: add no_fallback parameter #140

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions docs/photos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ Configure which file is used as default photo :

$default_photo = "images/240px-PICA.jpg";

Photo endpoint
--------------

A user's photo can be queried on ``/photo.php?dn=[user's DN]``. An additionnal
``no_fallback`` parameter can be passed to avoid falling back to a default
picture and returning 404: ``/photo.php?no_fallback&dn=[user's DN]``. This is
useful to eg. use an application's internal fallback image instead.

LDAP attribute
--------------

Expand Down
8 changes: 7 additions & 1 deletion htdocs/photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@
$result = "dnrequired";
}

# Display default photo if any error
if ( !$photo ) {
# If `no_fallback` in GET parameters, fail with 404
if(isset($_GET['no_fallback'])) {
http_response_code(404);
die();
}

# Else, display default photo if any error
$photo = imagecreatefromjpeg($default_photo);
}

Expand Down