7c7
<   <img> tags missing alt attributes are also marked with warning text to draw attention to
---
>   <img> tags missing alt attributes are also marked with warning text to draw attention to 
90,96c90,91
<   // code changes:
<   // - to prevent Undefined offset: 1 notices
<   // - minor optimizations (this code gets executed for each image tag in each node and block): bail out on any negative condition
<   // other possible optimization: make $active_class_array static and process the list of variables only once
< 	$img_tag = $img_tag_matches[0];
<   $return_text = $img_tag;
< 
---
>   $img_tag = $img_tag_matches[0];
>   
99c94
< 
---
>   
103,130c98,117
< 
<   // only execute this filter on img tags with (at least) one of the classes we are interested in
<   $has_class = preg_match ('/class=\"(.+?)\"/i', $img_tag, $matches) > 0;
<   if ($has_class) {
<     $class = $matches[1];
<     // formally, class is a space separated list of classes, but we allow all horizontal whitespace in any quantity
<     // that's why we use preg_split instead of explode
<     $classes = preg_split('/\h+/', $class, null, PREG_SPLIT_NO_EMPTY);
<     if (count(array_intersect($classes, $active_class_array)) > 0) {
<       // only execute this filter on img tags that have a title attribute
<       $has_title = preg_match ('/title=\"(.+?)\"/i', $img_tag, $matches) > 0;
<       if ($has_title) {
<         $title = $matches[1];
< 
<         // search for width specified as an inline style or width attribute,
<         // if no width specified, don't output it on the outer span, assume width will be handled with css external to this module/filter
<         $width = '';
<         if (preg_match ('/width:\s*(\d+)px/i', $img_tag, $matches) == 1 || preg_match ('/width=\"(\d+?)\"/i', $img_tag, $matches) == 1) {
<           $width = $matches[1];
<           $width = " style=\"width: {$width}px\"";
<         }
< 
<         // remove the class from the image tag
<         $img_tag = preg_replace ('/class=\"(.+?)\"/i', '', $img_tag);
< 
<         // add the outer and caption span
<         $return_text = "<span class=\"$class\"$width>$img_tag<span class=\"caption\">$title</span></span>";
<       }
---
>   
>   //get class out of the <img> tag
>   preg_match ('/class=\"(.+?)\"/i', $img_tag, $matches);
>   $class = $matches[1];
>   
>   //get the title out of the <img> tag
>   preg_match ('/title=\"(.+?)\"/i', $img_tag, $matches);
>   $title = $matches[1];
>   
>   //only modify the <img> tag if it is one of the classes we are interested in and has a title attribute
>   if (in_array($class, $active_class_array) && ($title)) {
>     //search for width specified as an inline style
>     if (preg_match ('/width:\s*(\d+)px/i', $img_tag, $matches) == 1) {
>       $width = $matches[1];
>       //else search for width specified as a width attribute
>     } else if (preg_match ('/width=\"(\d+?)\"/i', $img_tag, $matches) == 1) {
>       $width = $matches[1];
>     } else {
>       //no width specified, don't modify tag
>       return $img_tag;
131a119,125
>     
>     // remove the class from the image tag
>     $img_tag = preg_replace ('/class=\"(.+?)\"/i', '', $img_tag);
>     $return_text = "<span class=\"" . $class . "\" style=\"width: " . $width . "px\">"
>                     . $img_tag 
>                     . "<span class=\"caption\">" . $title . "</span></span>";
>     return $return_text;
133c127,128
<   return $return_text;
---
>   
>   return $img_tag;
