phpldapadmin/app/Classes/LDAP/Attribute/Binary/JpegPhoto.php

41 lines
969 B
PHP
Raw Normal View History

<?php
namespace App\Classes\LDAP\Attribute\Binary;
use App\Classes\LDAP\Attribute\Binary;
/**
2023-03-02 07:21:53 +00:00
* Represents an JpegPhoto Attribute
*/
final class JpegPhoto extends Binary
{
public function __construct(string $name,array $values)
{
parent::__construct($name,$values);
$this->internal = FALSE;
}
public function __toString(): string
{
// We'll use finfo to try and figure out what type of image is stored
$f = new \finfo;
$result = '<table class="table table-borderless p-0 m-0"><tr>';
foreach ($this->values as $value) {
switch ($x=$f->buffer($value,FILEINFO_MIME_TYPE)) {
case 'image/jpeg':
default:
$result .= sprintf('<td><img class="jpegphoto" src="data:%s;base64, %s" />%s</td>',
$x,
base64_encode($value),
2023-03-02 03:41:38 +00:00
$this->is_deletable ? sprintf('<br><span class="btn btn-sm btn-danger"><i class="fas fa-trash-alt"></i> %s</span>',__('Delete')) : '');
}
}
$result .= '</tr></table>';
return $result;
}
}