View Single Post
Old 04-26-2008, 02:42 PM  
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
Why don't you just do this in .htaccess, or set a <base href=.../>? What you're trying to fix shouldn't really be done that way. However, you can src=\"(/?) to just assume another localized request.

If you really want a semi-decent way to grab and rewrite your links:
Code:
$preg = "/[\s]+[^>]*?src[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/i";
   preg_match_all($preg,  $all_of_content_here, $outvar, PREG_PATTERN_ORDER);
Then just walk that to fix all hrefs. You can preg, or ereg if you want. I'll try to make that easy for ya with the following sample
Code:
foreach ($outvar as $imgsrc) {
  if (eregi($domain, $imgsrc)) {
   // is complete
  } elseif (eregi("^/", $imgsrc)) {
  // starts with a /
  } else {
  // assume it's local
  }
  }
__________________

Last edited by GrouchyAdmin; 04-26-2008 at 02:45 PM..
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote