public function getImageSrc($size = null)
    {
        $owner = $this->owner;

        $prefix = '';
        if (Yii::$app->request instanceof \yii\web\Request) {
            $prefix = Yii::$app->request->baseUrl;
            $host = Yii::$app->request->hostInfo;
            // If current application is backend - return absolute frontend image path
            if (!empty($this->_backendSubdomain) && strpos($host, $this->_backendSubdomain) !== false) {
                $prefix = str_replace($this->_backendSubdomain, '', $host) . $prefix;
            }
            if (!empty($this->_backendRoute) && strpos($prefix, $this->_backendRoute) !== false) {
                $prefix = str_replace($this->_backendRoute, '', $prefix);
            }
        }

        $image = $owner->{$this->_imageAttribute};
        if (empty($image)) {
            if (isset($this->getImageSizes()[$size])) {
                return $prefix . '/images/' . static::addPrefixToFile($this->_noImageBaseName, $size);
            }

            return $prefix . '/images/' . $this->_noImageBaseName;
        }

        $root = Yii::getAlias($this->_rootPathAlias); // Webroot
        $path = Yii::getAlias($this->_savePathAlias); // Uploading dir
        $path = str_replace($root, '', $path); // Remove server path
        $path = str_replace('\\', '/', $path); // Replace "\" to "/"
        $folder = $prefix . '/' . trim($path, '/') . '/';

        if (!empty($size)) {
            return $folder . static::addPrefixToFile($image, $size);
        } else {
            return $folder . $image;
        }
    }
public function getImageSrc($size = null)
    {
        $owner = $this->owner;

        $prefix = '';
        if (Yii::$app->request instanceof \yii\web\Request) {
            $prefix = Yii::$app->request->baseUrl;
            $host = Yii::$app->request->hostInfo;
            // If current application is backend - return absolute frontend image path
            if (!empty($this->_backendSubdomain) && strpos($host, $this->_backendSubdomain) !== false) {
                $prefix = str_replace($this->_backendSubdomain, '', $host) . $prefix;
            }
            if (!empty($this->_backendRoute) && strpos($prefix, $this->_backendRoute) !== false) {
                $prefix = str_replace($this->_backendRoute, '', $prefix);
            }
        }

        $image = $owner->{$this->_imageAttribute};
        if (empty($image)) {
            if (isset($this->getImageSizes()[$size])) {
                return $prefix . '/images/' . static::addPrefixToFile($this->_noImageBaseName, $size);
            }

            return $prefix . '/images/' . $this->_noImageBaseName;
        }

        $root = Yii::getAlias($this->_rootPathAlias); // Webroot
        $path = Yii::getAlias($this->_savePathAlias); // Uploading dir
        $path = str_replace($root, '', $path); // Remove server path
        $path = str_replace('\\', '/', $path); // Replace "\" to "/"
        $folder = $prefix . '/' . trim($path, '/') . '/';

        if (!empty($size)) {
            return $folder . static::addPrefixToFile($image, $size);
        } else {
            return $folder . $image;
        }
    }
public function getImageSrc ( $ size = null ) { $ owner = $ this -> owner ; $ prefix = '' ; if ( Yii :: $ app -> request instanceof \ yii \ web \ Request ) { $ prefix = Yii :: $ app -> request -> baseUrl ; $ host = Yii :: $ app -> request -> hostInfo ; // If current application is backend - return absolute frontend image path if ( ! empty ( $ this -> _backendSubdomain ) && strpos ( $ host , $ this -> _backendSubdomain ) !== false ) { $ prefix = str_replace ( $ this -> _backendSubdomain , '' , $ host ) . $ prefix ; } if ( ! empty ( $ this -> _backendRoute ) && strpos ( $ prefix , $ this -> _backendRoute ) !== false ) { $ prefix = str_replace ( $ this -> _backendRoute , '' , $ prefix ) ; } } $ image = $ owner -> { $ this -> _imageAttribute } ; if ( empty ( $ image ) ) { if ( isset ( $ this -> getImageSizes ( ) [ $ size ] ) ) { return $ prefix . '/images/' . static :: addPrefixToFile ( $ this -> _noImageBaseName , $ size ) ; } return $ prefix . '/images/' . $ this -> _noImageBaseName ; } $ root = Yii :: getAlias ( $ this -> _rootPathAlias ) ; // Webroot $ path = Yii :: getAlias ( $ this -> _savePathAlias ) ; // Uploading dir $ path = str_replace ( $ root , '' , $ path ) ; // Remove server path $ path = str_replace ( '\\' , '/' , $ path ) ; // Replace "\" to "/" $ folder = $ prefix . '/' . trim ( $ path , '/' ) . '/' ; if ( ! empty ( $ size ) ) { return $ folder . static :: addPrefixToFile ( $ image , $ size ) ; } else { return $ folder . $ image ; } }
Return image path for web

@param string $size Size prefix

@return string Image src path, can be value for Html::image()
Return image path for web