2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2007-12-06 02:26:34 +00:00
|
|
|
|
2023-01-10 22:44:09 +00:00
|
|
|
namespace Shimmie2;
|
|
|
|
|
2024-01-01 20:21:51 +00:00
|
|
|
use function MicroHTML\IMG;
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class PixelFileHandlerTheme extends Themelet
|
|
|
|
{
|
2024-01-15 14:23:00 +00:00
|
|
|
public function display_image(Image $image): void
|
2024-01-01 20:21:51 +00:00
|
|
|
{
|
|
|
|
global $config, $page;
|
|
|
|
|
|
|
|
$html = IMG([
|
|
|
|
'alt' => 'main image',
|
|
|
|
'class' => 'shm-main-image',
|
|
|
|
'id' => 'main_image',
|
|
|
|
'src' => $image->get_image_link(),
|
|
|
|
'data-width' => $image->width,
|
|
|
|
'data-height' => $image->height,
|
|
|
|
'data-mime' => $image->get_mime(),
|
2024-01-01 21:16:47 +00:00
|
|
|
'onerror' => "shm_log('Error loading >>{$image->id}')",
|
2024-01-01 20:21:51 +00:00
|
|
|
]);
|
|
|
|
$page->add_block(new Block("Image", $html, "main", 10));
|
|
|
|
}
|
|
|
|
|
2024-01-15 14:23:00 +00:00
|
|
|
public function display_metadata(Image $image): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2024-01-01 20:21:51 +00:00
|
|
|
global $page;
|
2009-08-09 21:00:59 +00:00
|
|
|
|
2024-01-01 20:21:51 +00:00
|
|
|
if (function_exists(ImageIO::EXIF_READ_FUNCTION)) {
|
2019-05-28 16:59:38 +00:00
|
|
|
# FIXME: only read from jpegs?
|
2020-03-25 10:50:32 +00:00
|
|
|
$exif = @exif_read_data($image->get_image_filename(), "IFD0", true);
|
2019-05-28 16:59:38 +00:00
|
|
|
if ($exif) {
|
|
|
|
$head = "";
|
|
|
|
foreach ($exif as $key => $section) {
|
|
|
|
foreach ($section as $name => $val) {
|
|
|
|
if ($key == "IFD0") {
|
2014-01-15 21:06:27 +00:00
|
|
|
// Cheap fix for array'd values in EXIF-data
|
|
|
|
if (is_array($val)) {
|
|
|
|
$val = implode(',', $val);
|
|
|
|
}
|
2019-05-28 16:59:38 +00:00
|
|
|
$head .= html_escape("$name: $val")."<br>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($head) {
|
|
|
|
$page->add_block(new Block("EXIF Info", $head, "left"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-06 02:26:34 +00:00
|
|
|
}
|