if alt="", then it gets outputted as [].

// ' [${1}] ' is the issue.
            preg_replace(
              '/<img\s[^>]*alt=["\']([^"\']*)["\'][^>]*>/i',
              variable_get('basic_metatags_use_alt_attribute', FALSE) ? ' [${1}] ' : '',
              $text
            )

Comments

avpaderno’s picture

Title: auto description from teaser: image alt empty, get [] » Auto description from node teaser: when the attribute alt is empty, the image tag is replaced by []

I think it should be enough to replace oreg_replace() with preg_replace_callback(); doing so, the code would replace the tag img with an empty string when the attribute alt is not present, and with the attribute alt surrounded by square brackets when the attribute alt is present.
The alternative is to use ${1} in the code shown.

avpaderno’s picture

Title: Auto description from node teaser: when the attribute alt is empty, the image tag is replaced by [] » Auto description from node teaser: when the attribute alt is empty, the tag img is replaced by []
Status: Active » Fixed

I opted for the easier solution, which was how version 6.x-1.0 worked.

If the code should be changed, feel free to re-open this issue.
Thanks for the report.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.