Jake Vanderwerf
4 hours ago 56a9a1ccf764ff7a6af8f8a2292cb07443cb4aa7
inc/utility/Image.php
@@ -21,6 +21,7 @@
      $this->imgData = Cache::for('imageData')->connect('post');
      if (JVB_TESTING) {
         $this->cache->flush();
         $this->imgData->flush();
      }
   }
@@ -95,7 +96,7 @@
            $postSlug,
            $postSlug,
            $imgSlug,
            $full[0]
            $full[0]??''
         );
         // Add gallery attributes to img tag
@@ -159,4 +160,30 @@
      return (new Image)->getImageData($imgID);
   }
   public static function gallery(string $ids, ?string $type = null):string
   {
      $ids = explode(',', $ids);
      $inner = implode('', array_map(function ($ID) {
         $caption = wp_get_attachment_caption($ID);
         if (!empty($caption)) {
            $caption = sprintf('<figcaption>%s</figcaption', $caption);
         }
         return sprintf(
            '<li><figure>%s%s</figure></li>',
            self::image($ID),
            $caption
         );
      }, $ids));
      return sprintf(
         '<ul class="gallery%s">%s</ul>',
         $type? ' '.$type : '',
         $inner
      );
   }
   public static function image(int $id, string $start = 'tiny', string $replace = 'large', bool $addLink = true, ?string $postSlug = null):string
   {
      return (new Image)->formatImage($id, $start, $replace, $addLink, $postSlug);
   }
}