<?php

use at\fanninger\kirby\extension\webhelper\WebHelper;
use at\fanninger\kirby\extension\imageext\ImageExt;
require_once 'kirbycms-extension-image-lib.php';
kirbytext::$pre[] = function ($kirbytext, $value) {
    $imageExt = new ImageExt($kirbytext->field->page);
    $value = $imageExt->parseAndConvertTags($value);
    return $value;
};
if (kirby()->option(ImageExt::CONFIG_PARAM_SUPPORT_TAG_IMAGE, 'false') === true) {
    unset(kirbytext::$tags['image']);
}
if (kirby()->option(ImageExt::CONFIG_PARAM_SUPPORT_TAG_GALLERY, 'false') === true) {
    unset(kirbytext::$tags['image_gallery']);
}
 public static function getTumb($page, $attr = array())
 {
     if (!is_array($attr) && count($attr) == 0) {
         return "";
     }
     $imageExt = new ImageExt($page);
     $imageExtImage = new ImageExtImage($imageExt);
     $imageExtImage->parse(ImageExtImage::TAG_IMAGE, array(), $attr);
     $imageExtImage->parseFileAttributes();
     $imageExtImage->optimizeOutput();
     if ($imageExt->isDebug()) {
         return $imageExtImage->getDebug();
     } else {
         $imageExtImage->generate();
         return $imageExtImage->toHTML();
     }
 }