[SensitiveContent] Don't crash in GNU social classic
When an attachment has no thumbnail (for example when it's a video).
This commit is contained in:
parent
13e8445083
commit
520a2ba202
@ -160,14 +160,23 @@ EOB;
|
||||
|
||||
$classes = "sensitive-blocker"; //'sensitive-blocker';
|
||||
|
||||
$thumbnail = null;
|
||||
try {
|
||||
$thumbnail = $file->getThumbnail();
|
||||
} catch (Exception $e) {
|
||||
$thumbnail = null;
|
||||
}
|
||||
$thumb_width_css = $thumbnail ? $thumbnail->width . 'px' : '100%';
|
||||
$thumb_height_css = $thumbnail ? $thumbnail->height . 'px' : '100%';
|
||||
|
||||
$out->elementStart('div', array(
|
||||
'class'=>'attachment-wrapper',
|
||||
'style'=>'height: ' . $file->getThumbnail()->height . 'px; width: ' . $file->getThumbnail()->width . 'px;'
|
||||
'class' => 'attachment-wrapper',
|
||||
'style' => "height: {$thumb_height_css}; width: {$thumb_width_css};",
|
||||
)); /*needs height of thumb*/
|
||||
$out->elementStart('div', array(
|
||||
'class'=>$classes,
|
||||
'onclick'=>'toggleSpoiler(event)',
|
||||
'style'=>'height: ' . $file->getThumbnail()->height . 'px; width: ' . $file->getThumbnail()->width . 'px;'
|
||||
'class' => $classes,
|
||||
'onclick' => 'toggleSpoiler(event)',
|
||||
'style' => "height: {$thumb_height_css}; width: {$thumb_width_css};",
|
||||
));
|
||||
$out->raw(' ');
|
||||
$out->elementEnd('div');
|
||||
|
Loading…
Reference in New Issue
Block a user