forked from Public/pics
Clean up and force a rebuild of thumbnails when customising a crop region.
This commit is contained in:
@@ -133,9 +133,9 @@ class Image extends Asset
|
||||
|
||||
public function removeAllThumbnails()
|
||||
{
|
||||
foreach ($this->thumbnails as $key => $value)
|
||||
foreach ($this->thumbnails as $key => $filename)
|
||||
{
|
||||
$thumb_path = THUMBSDIR . '/' . $this->subdir . '/' . $value;
|
||||
$thumb_path = THUMBSDIR . '/' . $this->subdir . '/' . $filename;
|
||||
if (is_file($thumb_path))
|
||||
unlink($thumb_path);
|
||||
}
|
||||
@@ -146,6 +146,30 @@ class Image extends Asset
|
||||
['id_asset' => $this->id_asset]);
|
||||
}
|
||||
|
||||
public function removeThumbnailsOfSize($width, $height)
|
||||
{
|
||||
foreach ($this->thumbnails as $key => $filename)
|
||||
{
|
||||
if (strpos($key, $width . 'x' . $height) !== 0)
|
||||
continue;
|
||||
|
||||
$thumb_path = THUMBSDIR . '/' . $this->subdir . '/' . $filename;
|
||||
if (is_file($thumb_path))
|
||||
unlink($thumb_path);
|
||||
}
|
||||
|
||||
return Registry::get('db')->query('
|
||||
DELETE FROM assets_thumbs
|
||||
WHERE id_asset = {int:id_asset} AND
|
||||
width = {int:width} AND
|
||||
height = {int:height}',
|
||||
[
|
||||
'height' => $height,
|
||||
'id_asset' => $this->id_asset,
|
||||
'width' => $width,
|
||||
]);
|
||||
}
|
||||
|
||||
public function replaceThumbnail($descriptor, $tmp_file)
|
||||
{
|
||||
if (!is_file($tmp_file))
|
||||
|
||||
Reference in New Issue
Block a user