From b38f03c0e7218762d90fa5092696b127f24f36db Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 25 Jan 2026 07:07:26 +0000
Subject: [PATCH] =Some logical flaws in Queue.php, Queue.js, ContentExecutor.php, UploadExecutor.php - particularly with timeline ordering, frontend queue updates, etc

---
 inc/utility/Image.php |   33 ++++++++++++++++++++++++++++-----
 1 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/inc/utility/Image.php b/inc/utility/Image.php
index 4901435..df5c2f3 100644
--- a/inc/utility/Image.php
+++ b/inc/utility/Image.php
@@ -1,7 +1,7 @@
 <?php
 namespace JVBase\utility;
 
-use JVBase\managers\CacheManager;
+use JVBase\managers\Cache;
 
 if (!defined('ABSPATH')) {
 	exit;
@@ -12,20 +12,22 @@
  */
 class Image
 {
-	protected ?CacheManager $cache = null;
+	protected ?Cache $cache = null;
+	protected ?Cache $imgData = null;
 
 	public function __construct()
 	{
-		$this->cache = CacheManager::for('images')->connectTo('post', 'attachment');
+		$this->cache = Cache::for('images')->connect('post');
+		$this->imgData = Cache::for('imageData')->connect('post');
 		if (JVB_TESTING) {
-			$this->cache->clear();
+			$this->cache->flush();
 		}
 	}
 
 	public function formatImage(int $ID, string $start = 'tiny', string $replace = 'large', bool $addLink = true, ?string $postSlug = null):string
 	{
 		$return = $this->cache->remember(
-			['ID' => $ID, 'start' => $start, 'replace' => $replace],
+			$this->cache->generateKey(['ID' => $ID, 'start' => $start, 'replace' => $replace]),
 			function() use ($ID, $start, $replace) {
 				// Define size order for progressive enhancement
 				$sizeOrder = ['tiny', 'directory-preview', 'thumbnail', 'medium', 'large', 'full'];
@@ -121,4 +123,25 @@
 		}
 		return '';
 	}
+
+	public function getImageData(int $imgID):array
+	{
+		return $this->imgData->remember(
+			$imgID,
+			function() use ($imgID) {
+				if (!wp_get_attachment_image($imgID, 'tiny')) {
+					return [];
+				}
+				return [
+					'tiny' 			=> wp_get_attachment_image_src($imgID, 'tiny')[0],
+					'small' 		=> wp_get_attachment_image_src($imgID, 'medium')[0],
+					'medium' 		=> wp_get_attachment_image_src($imgID, 'large')[0],
+					'large' 		=> wp_get_attachment_image_src($imgID, 'full')[0],
+					'image-alt-text'=> get_post_meta($imgID, '_wp_attachment_image_alt', true),
+					'image-title'	=> get_the_title($imgID),
+					'image-caption' => get_the_excerpt($imgID),
+				];
+			}
+		);
+	}
 }

--
Gitblit v1.10.0