mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-06 08:07:42 +02:00
adding support for alias #47
This commit is contained in:
31
CImage.php
31
CImage.php
@@ -2134,6 +2134,37 @@ class CImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a hard link, as an alias, to the cached file.
|
||||
*
|
||||
* @param string $alias where to store the link.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function linkToCacheFile($alias)
|
||||
{
|
||||
if ($alias === null) {
|
||||
$this->log("Ignore creating alias.");
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (is_readable($alias)) {
|
||||
unlink($alias);
|
||||
}
|
||||
|
||||
$res = link($this->cacheFileName, $alias);
|
||||
|
||||
if ($res) {
|
||||
$this->log("Created an alias to the cachefile: $alias");
|
||||
} else {
|
||||
$this->log("Failed to create the alias: $alias");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Output image to browser using caching.
|
||||
*
|
||||
|
Reference in New Issue
Block a user