update to kirby 4.8

This commit is contained in:
isUnknown 2026-02-13 15:40:11 +01:00
commit 7d7df341d1
636 changed files with 139949 additions and 0 deletions

View file

@ -0,0 +1,36 @@
<?php
Kirby::plugin('adrienpayet/content-size', [
'pageMethods' => [
'contentSize' => function () {
$contentSize = 0;
$site = site();
$html = $this->render();
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$currentDivs = $xpath->query('//div[contains(@class, "current")]');
if ($currentDivs->length > 0) {
$content = $dom->saveHTML($currentDivs->item(0));
$contentSize += strlen($content);
} else {
throw new Exception("No content div founded.", 1);
}
$images = $dom->getElementsByTagName('img');
foreach ($images as $image) {
$src = $image->getAttribute('src');
if (!empty($src)) {
$localSrc = str_replace($site->url(), realpath(__DIR__ . '/../../../'), $src);
$contentSize += filesize($localSrc);
}
}
return $contentSize;
}
]
]);