Start of using Attribute objects, rendering jpegphoto

This commit is contained in:
Deon George
2021-12-10 22:39:09 +11:00
parent dabca67fc8
commit 10a2d2161b
5 changed files with 20 additions and 52 deletions

View File

@@ -7,18 +7,19 @@ use App\Classes\LDAP\Attribute\Binary;
/**
* Represents an attribute whose values are jpeg pictures
*/
class JpegPhoto extends Binary
final class JpegPhoto extends Binary
{
public function __toString(): string
{
$result = '';
// We'll use finfo to try and figure out what type of image is stored
$f = new \finfo;
foreach ($this->values as $value) {
switch ($x=$f->buffer($value,FILEINFO_MIME_TYPE)) {
case 'image/jpeg':
default:
$result .= sprintf("<img style='display:block; width:100px;height:100px;' src='data:%s;base64, %s' />",$x,base64_encode($value));
$result .= sprintf('<img class="jpegphoto" src="data:%s;base64, %s" />',$x,base64_encode($value));
}
}