Start of using Attribute objects, rendering jpegphoto
This commit is contained in:
27
app/Classes/LDAP/Attribute/Binary/JpegPhoto.php
Normal file
27
app/Classes/LDAP/Attribute/Binary/JpegPhoto.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\LDAP\Attribute\Binary;
|
||||
|
||||
use App\Classes\LDAP\Attribute\Binary;
|
||||
|
||||
/**
|
||||
* Represents an attribute whose values are jpeg pictures
|
||||
*/
|
||||
class JpegPhoto extends Binary
|
||||
{
|
||||
public function __toString(): string
|
||||
{
|
||||
$result = '';
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user