mirror of
https://github.com/getgrav/grav.git
synced 2026-02-24 15:41:26 +01:00
Bug fixes for media
This commit is contained in:
@@ -624,7 +624,7 @@ trait ImageMediaTrait
|
||||
$file->touch();
|
||||
}
|
||||
|
||||
return $this->generateCacheImage(GRAV_WEBROOT . '/' . $imageFile);
|
||||
return $this->generateCacheImage(GRAV_WEBROOT . $imageFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -194,7 +194,7 @@ abstract class AbstractMedia implements ExportInterface, MediaCollectionInterfac
|
||||
public function current(): ?MediaObjectInterface
|
||||
{
|
||||
$instance = current($this->items);
|
||||
if ($instance && !$instance instanceof MediaObjectInterface) {
|
||||
if (false !== $instance && !$instance instanceof MediaObjectInterface) {
|
||||
// Initialize media object.
|
||||
$key = $this->key();
|
||||
$this->items[$key] = $instance = $this->initMedium($key);
|
||||
|
||||
@@ -47,7 +47,11 @@ abstract class LocalMedia extends AbstractMedia
|
||||
*/
|
||||
public function getPath(string $filename = null): ?string
|
||||
{
|
||||
return $this->path ? GRAV_WEBROOT . '/' . $this->path . ($filename ? '/' . $filename : '') : null;
|
||||
if (!$this->path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return GRAV_WEBROOT . '/' . $this->path . ($filename ? '/' . $filename : '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,11 +112,18 @@ class Medium extends Data implements RenderableInterface, MediaFileInterface
|
||||
*/
|
||||
public function getMeta(): array
|
||||
{
|
||||
return [
|
||||
// TODO: this may require some tweaking, works for now.
|
||||
$meta = $this->metadata + ($this->meta ?? []) + [
|
||||
'name' => $this->filename,
|
||||
'mime' => $this->mime,
|
||||
'size' => $this->size,
|
||||
'width' => $this->width,
|
||||
'height' => $this->height,
|
||||
'orientation' => $this->orientation,
|
||||
'modified' => $this->modified,
|
||||
];
|
||||
|
||||
return array_filter($meta, static function($val) { return $val !== null; } );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -936,7 +936,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
||||
if ($media && !$media instanceof LocalMedia) {
|
||||
$value = [];
|
||||
foreach ($media->all() as $medium) {
|
||||
$value[] = $medium->meta;
|
||||
$value[] = $medium->getMeta();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user