public static function path($url)
{
// remove line feeds and trailing whitespaces and path separators
$path = trim($url, " \t\r\n\v/\\");
$path = substr($path, strlen(self::SCHEME . '://'));
$path = str_replace('\\', '/', $path);
// replace double slashes with single slashes
$path = str_replace('//', '/', $path);
return rawurldecode($path);
}
public function successCompress($file) { if (preg_match('#[^-]+-([^.]+)[.](png|jpe?g)$#', basename($file), $match)) { $key = $match[1]; } else { $key = null; } $input = filesize($file); switch ($key) { case "thumbnail": $output = 81; break; case "medium": $output = 768; break; case "large": $output = 6789; break; case "post-thumbnail": $output = 1000; break; default: $output = 10000; } $this->vfs->getChild(vfsStream::path($file))->truncate($output); return array('input' => array('size' => $input), 'output' => array('size' => $output)); }