extension/ezjscore/classes/ezjscpacker.php
static function fixImgPaths( $fileContent, $file )
    {
        if ( preg_match_all( "/url\(\s*[\'|\"]?([A-Za-z0-9_\-\/\.\\%?&@#=]+)[\'|\"]?\s*\)/ix", $fileContent, $urlMatches ) )
        {
           $urlPaths = array();
           $urlMatches = array_unique( $urlMatches[1] );
           $cssPathArray   = explode( '/', $file );
           $wwwDir = self::getWwwDir();
           // Pop the css file name
           array_pop( $cssPathArray );
           $cssPathCount = count( $cssPathArray );
           foreach ( $urlMatches as $match )
           {
               $match = str_replace( '\\', '/', $match );
               $relativeCount = substr_count( $match, '../' );
               // Replace path if it is realtive
               if ( $match[0] !== '/' and strpos( $match, 'http:' ) === false )
               {
                   $cssPathSlice = $relativeCount === 0 ? $cssPathArray : array_slice( $cssPathArray  , 0, $cssPathCount - $relativeCount  );
                   $newMatchPath = $wwwDir;
                   if ( !empty( $cssPathSlice ) )
                   {
                       $newMatchPath .= implode( '/', $cssPathSlice ) . '/';
                   }
                   $newMatchPath .= str_replace( '../', '', $match );
                   $urlPaths[$match] = $newMatchPath;
               }
           }
           $fileContent = strtr( $fileContent, $urlPaths );
        }
        return $fileContent;
    }
static function fixImgPaths( $fileContent, $file )
    {
        if ( preg_match_all( "/url\(\s*[\'|\"]?([A-Za-z0-9_\-\/\.\\%?&@#=]+)[\'|\"]?\s*\)/ix", $fileContent, $urlMatches ) )
        {
           $urlPaths = array();
           $urlMatches = array_unique( $urlMatches[1] );
           $cssPathArray   = explode( '/', $file );
           $wwwDir = self::getWwwDir();
           // Pop the css file name
           array_pop( $cssPathArray );
           $cssPathCount = count( $cssPathArray );
           foreach ( $urlMatches as $match )
           {
               $match = str_replace( '\\', '/', $match );
               $relativeCount = substr_count( $match, '../' );
               // Replace path if it is realtive
               if ( $match[0] !== '/' and strpos( $match, 'http:' ) === false )
               {
                   $cssPathSlice = $relativeCount === 0 ? $cssPathArray : array_slice( $cssPathArray  , 0, $cssPathCount - $relativeCount  );
                   $newMatchPath = $wwwDir;
                   if ( !empty( $cssPathSlice ) )
                   {
                       $newMatchPath .= implode( '/', $cssPathSlice ) . '/';
                   }
                   $newMatchPath .= str_replace( '../', '', $match );
                   $urlPaths[$match] = $newMatchPath;
               }
           }
           $fileContent = strtr( $fileContent, $urlPaths );
        }
        return $fileContent;
    }
static function fixImgPaths ( $ fileContent , $ file ) { if ( preg_match_all ( "/url\(\s*[\'|\"]?([A-Za-z0-9_\-\/\.\\%?&@#=]+)[\'|\"]?\s*\)/ix" , $ fileContent , $ urlMatches ) ) { $ urlPaths = array ( ) ; $ urlMatches = array_unique ( $ urlMatches [ 1 ] ) ; $ cssPathArray = explode ( '/' , $ file ) ; $ wwwDir = self :: getWwwDir ( ) ; // Pop the css file name array_pop ( $ cssPathArray ) ; $ cssPathCount = count ( $ cssPathArray ) ; foreach ( $ urlMatches as $ match ) { $ match = str_replace ( '\\' , '/' , $ match ) ; $ relativeCount = substr_count ( $ match , '../' ) ; // Replace path if it is realtive if ( $ match [ 0 ] !== '/' and strpos ( $ match , 'http:' ) === false ) { $ cssPathSlice = $ relativeCount === 0 ? $ cssPathArray : array_slice ( $ cssPathArray , 0 , $ cssPathCount - $ relativeCount ) ; $ newMatchPath = $ wwwDir ; if ( ! empty ( $ cssPathSlice ) ) { $ newMatchPath .= implode ( '/' , $ cssPathSlice ) . '/' ; } $ newMatchPath .= str_replace ( '../' , '' , $ match ) ; $ urlPaths [ $ match ] = $ newMatchPath ; } } $ fileContent = strtr ( $ fileContent , $ urlPaths ) ; } return $ fileContent ; }
Fix image paths in css.

@param string $fileContent Css string
@param string $file File incl path to calculate relative paths from.
@return string
Fix image paths in css .