Merge pull request #12214 from Schnoop/bugfix/DivisionByZero
Prevent division by zero in Mastodon Attachment.
This commit is contained in:
commit
acc3c2d2c7
|
@ -63,15 +63,19 @@ class Attachment extends BaseDataTransferObject
|
||||||
$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') {
|
if ($type === 'image') {
|
||||||
$this->meta['original']['width'] = (int) $attachment['width'];
|
if ((int) $attachment['width'] > 0 && (int) $attachment['height'] > 0) {
|
||||||
$this->meta['original']['height'] = (int) $attachment['height'];
|
$this->meta['original']['width'] = (int) $attachment['width'];
|
||||||
$this->meta['original']['size'] = (int) $attachment['width'] . 'x' . (int) $attachment['height'];
|
$this->meta['original']['height'] = (int) $attachment['height'];
|
||||||
$this->meta['original']['aspect'] = (float) ((int) $attachment['width'] / (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'];
|
if ((int) $attachment['preview-width'] > 0 && (int) $attachment['preview-height'] > 0) {
|
||||||
$this->meta['small']['height'] = (int) $attachment['preview-height'];
|
$this->meta['small']['width'] = (int) $attachment['preview-width'];
|
||||||
$this->meta['small']['size'] = (int) $attachment['preview-width'] . 'x' . (int) $attachment['preview-height'];
|
$this->meta['small']['height'] = (int) $attachment['preview-height'];
|
||||||
$this->meta['small']['aspect'] = (float) ((int) $attachment['preview-width'] / (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 New Issue
Block a user