Skip to content

Commit

Permalink
Merge pull request #140 from tobast/tbastian/photo_no_fallback
Browse files Browse the repository at this point in the history
Photo.php: add no_fallback parameter
  • Loading branch information
coudot authored Jun 26, 2024
2 parents 740f100 + 4978983 commit 3f00fb4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit 3f00fb4

Please sign in to comment.