vBulletin: alt attribute conversion could be improved

Kirby

Well-known member
Affected version
1.5.2
PHP:
if (!empty($settings['title']))
{
    $attributes['alt'] = $this->convertToUtf8($settings['title']);
}
if (!empty($settings['description']))
{
    $description = preg_replace( '/[\r\n]/', ' ', $this->convertToUtf8($settings['description']));

    if (isset($attributes['alt']))
    {
        $attributes['alt'] .= " - $description";
    }
    else
    {
        $attributes['alt'] = $description;
    }
}

If an attachment has title and description and both are identical, the resulting alt attribute is <title> - <title> which doesn't make much sense.

Suggested Change
PHP:
if (isset($attributes['alt']) && $description !== $attributes['alt'])
to avoid title duplication.
 

Similar threads

Back
Top Bottom