Esempio n. 1
0
 public static function getSrcWithResize($file = array(), $size = array())
 {
     $file1 = \CFile::ResizeImageGet($file["ID"], $size, BX_RESIZE_IMAGE_PROPORTIONAL, false);
     $src = $file1['src'];
     if ($file['HANDLER_ID'] > 0) {
         $src = "/" . \COption::GetOptionString("main", "upload_dir", "upload") . "/" . $file["SUBDIR"] . "/" . $file["FILE_NAME"];
         $path = $_SERVER["DOCUMENT_ROOT"] . $src;
         if (!(is_file($path) && file_exists($path))) {
             $sign = new Signer();
             $s = $sign->sign($file["ID"] . "x" . $size["width"] . "x" . $size["height"], self::$salt);
             $src = \COption::GetOptionString("main.fileinput", "entryPointUrl", "/bitrix/tools/upload.php") . "?" . http_build_query(array("action" => "uncloud", "mode" => "resize", "file" => $file["ID"], "width" => $size["width"], "height" => $size["height"], "signature" => $s));
         }
     } else {
         $src = \Bitrix\Main\IO\Path::convertLogicalToUri($src);
     }
     return $src;
 }
Esempio n. 2
0
	/**
	 * Returns file relative path for URL.
	 *
	 * @param File $f File object.
	 *
	 * @return string
	 */
	protected function getFileUrl(File $f)
	{
		static $indexNames;
		if(!is_array($indexNames))
		{
			$indexNames = GetDirIndexArray();
		}

		$path = '/';
		if (substr($this->path, 0, strlen($this->documentRoot)) === $this->documentRoot)
		{
			$path = '/'.substr($f->getPath(), strlen($this->documentRoot));
		}

		$path = Path::convertLogicalToUri($path);

		$path = in_array($f->getName(), $indexNames)
			? str_replace('/'.$f->getName(), '/', $path)
			: $path;

		return '/'.ltrim($path, '/');
	}