Add meta tag to attachment to show images in mastodon app.
This commit is contained in:
parent
e354f48765
commit
74b10708ae
1 changed files with 13 additions and 0 deletions
|
@ -44,6 +44,8 @@ class Attachment extends BaseDataTransferObject
|
||||||
protected $text_url;
|
protected $text_url;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $description;
|
protected $description;
|
||||||
|
/** @var array */
|
||||||
|
protected $meta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an attachment
|
* Creates an attachment
|
||||||
|
@ -60,6 +62,17 @@ class Attachment extends BaseDataTransferObject
|
||||||
$this->remote_url = $remote;
|
$this->remote_url = $remote;
|
||||||
$this->text_url = $this->remote_url ?? $this->url;
|
$this->text_url = $this->remote_url ?? $this->url;
|
||||||
$this->description = $attachment['description'];
|
$this->description = $attachment['description'];
|
||||||
|
if ($type === 'image') {
|
||||||
|
$this->meta['original']['width'] = (int) $attachment['width'];
|
||||||
|
$this->meta['original']['height'] = (int) $attachment['height'];
|
||||||
|
$this->meta['original']['size'] = (int) $attachment['width'] . 'x' . (int) $attachment['height'];
|
||||||
|
$this->meta['original']['aspect'] = (float) ((int) $attachment['width'] / (int) $attachment['height']);
|
||||||
|
|
||||||
|
$this->meta['small']['width'] = (int) $attachment['preview-width'];
|
||||||
|
$this->meta['small']['height'] = (int) $attachment['preview-height'];
|
||||||
|
$this->meta['small']['size'] = (int) $attachment['preview-width'] . 'x' . (int) $attachment['preview-height'];
|
||||||
|
$this->meta['small']['aspect'] = (float) ((int) $attachment['preview-width'] / (int) $attachment['preview-height']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue