diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php
index 99de66617..e59fd709b 100644
--- a/app/Controllers/Items.php
+++ b/app/Controllers/Items.php
@@ -167,48 +167,45 @@ class Items extends Secure_Controller
{
helper('file');
- $file_extension = pathinfo($pic_filename, PATHINFO_EXTENSION);
- $upload_path = FCPATH . 'uploads/item_pics/';
+ $fileExtension = pathinfo($pic_filename, PATHINFO_EXTENSION);
+ $uploadPath = FCPATH . 'uploads/item_pics/';
- // Handle files with and without extensions
- if (empty($file_extension)) {
- $images = glob($upload_path . $pic_filename . '.*');
- } else {
- $images = glob($upload_path . $pic_filename);
- }
+ $images = empty($fileExtension)
+ ? glob($uploadPath . $pic_filename . '.*')
+ : glob($uploadPath . $pic_filename);
if (sizeof($images) > 0) {
- $image_path = $images[0];
- $actual_extension = pathinfo($image_path, PATHINFO_EXTENSION);
- $base_path = $upload_path . pathinfo($pic_filename, PATHINFO_FILENAME);
- $thumb_path = $base_path . "_thumb.$actual_extension";
+ $imagePath = $images[0];
+ $actualExtension = pathinfo($imagePath, PATHINFO_EXTENSION);
+ $basePath = $uploadPath . pathinfo($pic_filename, PATHINFO_FILENAME);
+ $thumbPath = $basePath . "_thumb.$actualExtension";
// Try to create thumbnail if it doesn't exist
- if (!file_exists($thumb_path)) {
+ if (!file_exists($thumbPath)) {
try {
$image = Services::image('gd2');
- $image->withFile($image_path)
+ $image->withFile($imagePath)
->resize(52, 32, true, 'height')
- ->save($thumb_path);
+ ->save($thumbPath);
} catch (Exception $e) {
// If thumbnail creation fails, serve original image
log_message('error', 'Thumbnail creation failed: ' . $e->getMessage());
- $this->serveImage($image_path);
+ $this->serveImage($imagePath);
return;
}
}
// Serve thumbnail if it exists, otherwise serve original
- if (file_exists($thumb_path)) {
- $this->serveImage($thumb_path);
+ if (file_exists($thumbPath)) {
+ $this->serveImage($thumbPath);
} else {
- $this->serveImage($image_path);
+ $this->serveImage($imagePath);
}
} else {
// No image found, serve default
- $default_image = FCPATH . 'public/images/no-img.png';
- if (file_exists($default_image)) {
- $this->serveImage($default_image);
+ $defaultImage = FCPATH . 'public/images/no-img.png';
+ if (file_exists($defaultImage)) {
+ $this->serveImage($defaultImage);
} else {
// Return 404 if no default image
$this->response->setStatusCode(404);
diff --git a/app/Helpers/tabular_helper.php b/app/Helpers/tabular_helper.php
index 9f009f183..731f82535 100644
--- a/app/Helpers/tabular_helper.php
+++ b/app/Helpers/tabular_helper.php
@@ -464,24 +464,24 @@ function get_item_data_row(object $item): array
$image = '';
if (!empty($item->pic_filename)) {
- $upload_path = FCPATH . 'uploads/item_pics/';
+ $uploadPath = FCPATH . 'uploads/item_pics/';
$ext = pathinfo($item->pic_filename, PATHINFO_EXTENSION);
// If no extension in filename, search for any file with that name
if (empty($ext)) {
- $pattern = $upload_path . $item->pic_filename . '.*';
+ $pattern = $uploadPath . $item->pic_filename . '.*';
} else {
- $pattern = $upload_path . $item->pic_filename;
+ $pattern = $uploadPath . $item->pic_filename;
}
$images = glob($pattern);
if (!empty($images)) {
- $rel_path = 'uploads/item_pics/' . basename($images[0]);
+ $relPath = 'uploads/item_pics/' . basename($images[0]);
// Use direct image path instead of getPicThumb
- $image = '
-
+
';
diff --git a/test_avatar_toggle.html b/test_avatar_toggle.html
deleted file mode 100644
index 6efdbc83f..000000000
--- a/test_avatar_toggle.html
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
| Image | -Description | -Price | -Quantity | -Total | -
|---|---|---|---|---|
|
- |
- Test Item 1 | -$10.00 | -2 | -$20.00 | -
|
- |
- Test Item 2 | -$15.00 | -1 | -$15.00 | -