- $id = $umatch[2];
- $imgObj = DB_DataObject::factory('Images');
- if (!$imgObj->get($id)) {
- continue;
- }
- $type = explode('/', $umatch[1]);
- $thumbsize = -1;
- $new_thumbsize = -1;
+ $html = self::replaceImgUrl($html, $baseURL, $img, $attr, $attr['src'] );
+ }
+ }
+ static function replaceImgUrl($html, $baseURL, $tag, $attr, $attr_url)
+
+
+ //print_R($attr);
+ // see if it's an image url..
+ // Images/{ID}/fullname.xxxx
+ // Images/Thumb/200/{ID}/fullname.xxxx
+ // Images/Download/{ID}/fullname.xxxx
+ $umatch = false;
+ if(!preg_match('#/(Images|Images/Thumb/[a-z0-9]+|Images/Download)/([0-9]+)/(.*)$#', $attr_url, $umatch)) {
+ continue;
+ }
+ $id = $umatch[2];
+ $img = DB_DataObject::factory('Images');
+ if (!$imgObj->get($id)) {
+ return $html;
+ }
+ $type = explode('/', $umatch[1]);
+ $thumbsize = -1;
+ $new_thumbsize = -1;
+
+ if (count($type) > 2 && $type[1] == 'Thumb') {
+ $thumbsize = $type[2];
+ $provider = 'Images/Thumb';
+ } else {
+ $provider = $umatch[1];
+ }
+
+ if (!empty($attr['width']) || !empty($attr['height']) )
+ {
+ // no support for %...
+ $new_thumbsize =
+ (empty($attr['width']) ? '0' : $attr['width'] * 1) .
+ 'x' .
+ (empty($attr['height']) ? '0' : $attr['height'] * 1);