SensitiveContentPlugin: don't crash in GNU/Social Classic,

when an attachment has no thumbnail (for example when it is a video)
This commit is contained in:
nee 2016-11-02 04:56:29 +01:00
parent a096bbe0cf
commit 186d730468
1 changed files with 11 additions and 2 deletions

View File

@ -160,14 +160,23 @@ EOB;
$classes = "sensitive-blocker"; //'sensitive-blocker'; $classes = "sensitive-blocker"; //'sensitive-blocker';
$thumbnail = null;
try {
$thumbnail = $file->getThumbnail();
} catch (Exception $e) {
$thumbnail = null;
}
$thumbWidth = $thumbnail ? $thumbnail->width : 'auto';
$thumbHeight = $thumbnail ? $thumbnail->height : 'auto';
$out->elementStart('div', array( $out->elementStart('div', array(
'class'=>'attachment-wrapper', 'class'=>'attachment-wrapper',
'style'=>'height: ' . $file->getThumbnail()->height . 'px; width: ' . $file->getThumbnail()->width . 'px;' 'style'=>'height: ' . $thumbHeight . 'px; width: ' . $thumbWidth . 'px;'
)); /*needs height of thumb*/ )); /*needs height of thumb*/
$out->elementStart('div', array( $out->elementStart('div', array(
'class'=>$classes, 'class'=>$classes,
'onclick'=>'toggleSpoiler(event)', 'onclick'=>'toggleSpoiler(event)',
'style'=>'height: ' . $file->getThumbnail()->height . 'px; width: ' . $file->getThumbnail()->width . 'px;' 'style'=>'height: ' . $thumbHeight . 'px; width: ' . $thumbWidth . 'px;'
)); ));
$out->raw(' '); $out->raw(' ');
$out->elementEnd('div'); $out->elementEnd('div');