Added Medium::size()

This commit is contained in:
Matias Griese
2019-03-01 14:47:53 +02:00
parent 8fb7caa22a
commit 1762ef3d1e
2 changed files with 21 additions and 1 deletions

View File

@@ -16,6 +16,12 @@ use Grav\Common\Data\Blueprint;
use Grav\Common\Media\Interfaces\MediaObjectInterface;
use Grav\Common\Utils;
/**
* Class Medium
* @package Grav\Common\Page\Medium
*
* @property string $mime
*/
class Medium extends Data implements RenderableInterface, MediaObjectInterface
{
use ParsedownHtmlTrait;
@@ -137,6 +143,20 @@ class Medium extends Data implements RenderableInterface, MediaObjectInterface
return filemtime($path) ?: null;
}
/**
* @return int
*/
public function size()
{
$path = $this->get('filepath');
if (!file_exists($path)) {
return 0;
}
return filesize($path) ?: 0;
}
/**
* Set querystring to file modification timestamp (or value provided as a parameter).
*

View File

@@ -685,7 +685,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
$this->_storage['storage_timestamp'] = (int)$elements['storage_timestamp'];
}
unset ($elements['storage_key'], $elements['storage_timestamp']);
unset ($elements['storage_key'], $elements['storage_timestamp'], $elements['_post_entries_save']);
}
/**