get('system.media.enable_media_timestamp', true)) { $this->timestamp = Grav::instance()['cache']->getKey(); } $this->def('mime', 'application/octet-stream'); if (!$this->offsetExists('size')) { $path = $this->get('filepath'); $this->def('size', filesize($path)); } $this->reset(); } /** * Clone medium. */ #[\ReturnTypeWillChange] public function __clone() { // Allows future compatibility as parent::__clone() works. } /** * Add meta file for the medium. * * @param string $filepath */ public function addMetaFile($filepath) { $this->metadata = (array)CompiledYamlFile::instance($filepath)->content(); $this->merge($this->metadata); } /** * @return array */ public function getMeta(): array { return [ 'mime' => $this->mime, 'size' => $this->size, 'modified' => $this->modified, ]; } /** * Return string representation of the object (html). * * @return string */ #[\ReturnTypeWillChange] public function __toString() { return $this->html(); } /** * @param string $thumb * @return Medium|null */ protected function createThumbnail($thumb) { return MediumFactory::fromFile($thumb, ['type' => 'thumbnail']); } /** * @param array $attributes * @return MediaLinkInterface */ protected function createLink(array $attributes) { return new Link($attributes, $this); } /** * @return Grav */ protected function getGrav(): Grav { return Grav::instance(); } /** * @return array */ protected function getItems(): array { return $this->items; } }