fix bug on regex components

The trim and preg_match function were using $link[1] as argument, which, according to the previous regex, always contains a string with value "img". I changed it to $link[2] which actually contains the image url and I guess was the original author intent.