mirror of
https://github.com/getgrav/grav.git
synced 2026-06-20 14:20:41 +02:00
Added Medium::size()
This commit is contained in:
@@ -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).
|
||||
*
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user