From a5708f168f3ab3c89eb509c7291d0ce69dc7fdc9 Mon Sep 17 00:00:00 2001 From: emak Date: Fri, 29 Oct 2021 16:37:11 -0400 Subject: [PATCH] Add device image support from provisioning templates (#5994) This change adds support for images of the current selected device on the device_edit.php page. The images need to be stored with the provisioning templates in the following format: * /yealink/t21p/t21p.jpg Images loaded into the page without needing link to the direct path. This makes it possible to store images with the template and not need any form of nginx rewrite rule or any other changes. The images are zoomable with pure CSS, no javascript required. --- app/devices/device_edit.php | 52 ++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 1b198ee4ea..4c8e5b60b9 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -895,6 +895,7 @@ echo "

\n"; echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; }
\n"; echo " ".$text['label-device_mac_address']."\n"; @@ -935,9 +936,10 @@ echo " ".$text['label-device_template']."\n"; echo "\n"; + echo "
"; $device = new device; $template_dir = $device->get_template_dir(); - echo " \n"; echo " \n"; if (is_dir($template_dir) && @is_array($device_vendors)) { foreach ($device_vendors as $row) { @@ -950,6 +952,8 @@ if (is_dir($template_dir . '/' . $row["name"] .'/'. $dir)) { if ($device_template == $row["name"]."/".$dir) { echo " \n"; + $current_device = escape($dir); + $current_device_path = $template_dir . '/' . $row["name"]; } else { echo " \n"; @@ -963,8 +967,54 @@ } } echo " \n"; + echo " \n"; echo " ".$text['description-device_template']."\n"; + echo " "; + echo "
"; + echo " + + "; + + $device_image_path = $current_device_path . "/"; + $device_image_name = $current_device . ".jpg"; + $device_image_full = $device_image_path . "/" . $current_device . "/" . $device_image_name; + + if (file_exists($device_image_full)) + { + $device_image = base64_encode(file_get_contents($device_image_full)); + + echo "
\n"; + echo ""; + echo "
"; + } echo "