19 declare(strict_types=1);
66 public function __construct(
string $a_tex,
string $a_type,
int $a_dpi)
70 $this->fs = $DIC->filesystem()->web();
75 $this->suffix =
'.png';
78 $this->suffix =
'.svg';
84 $this->salt =
'#' . $a_dpi;
92 $hash = md5($this->tex . $this->salt);
93 return $this->basepath
94 .
'/' . substr($hash, 0, 4)
95 .
'/' . substr($hash, 4, 4);
103 $hash = md5($this->tex . $this->salt);
120 return $this->fs->has($this->
filepath());
128 return $this->fs->read($this->
filepath());
135 public function write(
string $a_content): void
142 foreach (explode(
'/', $this->
filedir()) as $part) {
144 $dir = $dir .
'/' . $part;
146 if (!$this->fs->hasDir($dir)) {
147 $this->fs->createDir($dir, Visibility::PUBLIC_ACCESS);
149 $this->fs->setVisibility($dir, Visibility::PUBLIC_ACCESS);
152 $this->fs->put($this->
filepath(), $a_content);
161 if ($this->fs->hasDir($this->basepath)) {
162 foreach ($this->fs->finder()->in([$this->basepath])->files() as $meta) {
163 $size += $this->fs->getSize($meta->getPath(), 1)->inBytes();
167 $type = array(
"K",
"M",
"G",
"T",
"P",
"E",
"Z",
"Y");
170 while ($size >= 1000) {
175 return (round($size, 1) .
" " . $type[$counter] .
"B");
183 $this->fs->deleteDir($this->basepath);
Rendered MathJax image Supports image types SVG or PNG Files are stored in the web file system of ili...
filepath()
Get the relative file path of the image.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
absolutePath()
Get the absolute path of the image.
clearCache()
Delete all files from the cache.
getCacheSize()
Get the total size of the cache with an appropriate unit for display.
read()
Read the content of a cached image.
__construct(string $a_tex, string $a_type, int $a_dpi)
exists()
Check if an image is cached.
filedir()
Get the relative directory path of the image.
write(string $a_content)
Save the content of a cached image.