\XF\Entity\Thread::getCoverImage does not consider all thumbnails as candidates

Kirby

Well-known member
Affected version
2.2.13
PHP:
$attachments = $attachments->filter(function(Attachment $attachment) use ($canViewAttachments)
{
    if ($attachment->type_grouping != 'image')
    {
        return false;
    }

    return $canViewAttachments || $attachment->hasThumbnail();
});

This code ignores attachments that have thumbnails but are not grouped as images.

Changing this to
PHP:
$attachments = $attachments->filter(function(Attachment $attachment) use ($canViewAttachments)
{
    return $canViewAttachments || $attachment->hasThumbnail();
});

and also (2x)
PHP:
$coverImageUrl = $canViewAttachments

to

PHP:
$coverImageUrl = ($canViewAttachments && $attachment->type_grouping === 'image')

seems to fix this.
 
Back
Top Bottom