src/Filter/TimestampImage.php
protected function _replace($matches)
    {
        $webroot = null;
        if (defined('WWW_ROOT')) {
            $webroot = WWW_ROOT;
        }
        if (!empty($this->_settings['webroot'])) {
            $webroot = $this->_settings['webroot'];
        }

        $path = $matches['path'];
        if ($path[0] === '/') {
            $imagePath = $webroot . rtrim($path, '/');
        } else {
            $imagePath = realpath(dirname($this->_filename) . DIRECTORY_SEPARATOR . $path);
        }
        if (file_exists($imagePath)) {
            $path = $this->_timestamp($imagePath, $path);
        }
        return $matches['prop'] . $path . $matches['trail'];
    }
protected function _replace($matches)
    {
        $webroot = null;
        if (defined('WWW_ROOT')) {
            $webroot = WWW_ROOT;
        }
        if (!empty($this->_settings['webroot'])) {
            $webroot = $this->_settings['webroot'];
        }

        $path = $matches['path'];
        if ($path[0] === '/') {
            $imagePath = $webroot . rtrim($path, '/');
        } else {
            $imagePath = realpath(dirname($this->_filename) . DIRECTORY_SEPARATOR . $path);
        }
        if (file_exists($imagePath)) {
            $path = $this->_timestamp($imagePath, $path);
        }
        return $matches['prop'] . $path . $matches['trail'];
    }
protected function _replace ( $ matches ) { $ webroot = null ; if ( defined ( 'WWW_ROOT' ) ) { $ webroot = WWW_ROOT ; } if ( ! empty ( $ this -> _settings [ 'webroot' ] ) ) { $ webroot = $ this -> _settings [ 'webroot' ] ; } $ path = $ matches [ 'path' ] ; if ( $ path [ 0 ] === '/' ) { $ imagePath = $ webroot . rtrim ( $ path , '/' ) ; } else { $ imagePath = realpath ( dirname ( $ this -> _filename ) . DIRECTORY_SEPARATOR . $ path ) ; } if ( file_exists ( $ imagePath ) ) { $ path = $ this -> _timestamp ( $ imagePath , $ path ) ; } return $ matches [ 'prop' ] . $ path . $ matches [ 'trail' ] ; }
Do replacements.

- $matches[0] -> whole background line.
- $matches[path] -> the url with any wrapping '/'

If the image path starts with / its assumed to be an absolute path
which will be prepended with settings[webroot] or WWW_ROOT

@param array $matches Array of matches
@return string Replaced code.
Do replacements .