2021-12-08 12:26:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Classes\LDAP\Attribute\Binary;
|
|
|
|
|
|
|
|
use App\Classes\LDAP\Attribute\Binary;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents an attribute whose values are jpeg pictures
|
|
|
|
*/
|
2021-12-10 11:39:09 +00:00
|
|
|
final class JpegPhoto extends Binary
|
2021-12-08 12:26:12 +00:00
|
|
|
{
|
|
|
|
public function __toString(): string
|
|
|
|
{
|
|
|
|
$result = '';
|
2021-12-10 11:39:09 +00:00
|
|
|
// We'll use finfo to try and figure out what type of image is stored
|
2021-12-08 12:26:12 +00:00
|
|
|
$f = new \finfo;
|
|
|
|
|
|
|
|
foreach ($this->values as $value) {
|
|
|
|
switch ($x=$f->buffer($value,FILEINFO_MIME_TYPE)) {
|
|
|
|
case 'image/jpeg':
|
|
|
|
default:
|
2021-12-10 11:39:09 +00:00
|
|
|
$result .= sprintf('<img class="jpegphoto" src="data:%s;base64, %s" />',$x,base64_encode($value));
|
2021-12-08 12:26:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|