CImage.php
public function setSource($src, $dir = null)
    {
        if (!isset($src)) {
            $this->imageSrc = null;
            $this->pathToImage = null;
            return $this;
        }

        if ($this->allowRemote && $this->isRemoteSource($src)) {
            $src = $this->downloadRemoteSource($src);
            $dir = null;
        }

        if (!isset($dir)) {
            $dir = dirname($src);
            $src = basename($src);
        }

        $this->imageSrc     = ltrim($src, '/');
        $imageFolder        = rtrim($dir, '/');
        $this->pathToImage  = $imageFolder . '/' . $this->imageSrc;

        return $this;
    }
public function setSource($src, $dir = null)
    {
        if (!isset($src)) {
            $this->imageSrc = null;
            $this->pathToImage = null;
            return $this;
        }

        if ($this->allowRemote && $this->isRemoteSource($src)) {
            $src = $this->downloadRemoteSource($src);
            $dir = null;
        }

        if (!isset($dir)) {
            $dir = dirname($src);
            $src = basename($src);
        }

        $this->imageSrc     = ltrim($src, '/');
        $imageFolder        = rtrim($dir, '/');
        $this->pathToImage  = $imageFolder . '/' . $this->imageSrc;

        return $this;
    }
public function setSource ( $ src , $ dir = null ) { if ( ! isset ( $ src ) ) { $ this -> imageSrc = null ; $ this -> pathToImage = null ; return $ this ; } if ( $ this -> allowRemote && $ this -> isRemoteSource ( $ src ) ) { $ src = $ this -> downloadRemoteSource ( $ src ) ; $ dir = null ; } if ( ! isset ( $ dir ) ) { $ dir = dirname ( $ src ) ; $ src = basename ( $ src ) ; } $ this -> imageSrc = ltrim ( $ src , '/' ) ; $ imageFolder = rtrim ( $ dir , '/' ) ; $ this -> pathToImage = $ imageFolder . '/' . $ this -> imageSrc ; return $ this ; }
Set source file to use as image source.

@param string $src of image.
@param string $dir as optional base directory where images are.

@return $this
Set source file to use as image source .