public function __async_edit($imageId)
    {
        /** @var array $result Result of asynchronous controller */
        $result = array('status' => false);
        /** @var \samson\activerecord\gallery $image Image to insert into editor */
        $image = null;
        /** @var resource $imageResource Copy of edit image */
        $imageResource = null;
        /** @var resource $croppedImage Resource of cropped image */
        $croppedImage = null;

        // If there is such image in database
        if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)->where('PhotoID', $imageId)->first($image)) {

            // Form proper path
            $path = $this->formImagePath($image->Path, $image->Src);

            // Check image extension
            switch (pathinfo($path, PATHINFO_EXTENSION)) {
                case 'jpeg':
                case 'jpg':
                    $imageResource = imagecreatefromjpeg($path);
                    $croppedImage = $this->cropImage($imageResource);
                    $result['status'] = imagejpeg($croppedImage, $path);
                    break;
                case 'png':
                    $imageResource = imagecreatefrompng($path);
                    $croppedImage = $this->cropTransparentImage($imageResource);
                    $result['status'] = imagepng($croppedImage, $path);
                    break;
                case 'gif':
                    $imageResource = imagecreatefromgif($path);
                    $croppedImage = $this->cropTransparentImage($imageResource);
                    $result['status'] = imagegif($croppedImage, $path);
                    break;
            }

            // delete temporary images
            imagedestroy($croppedImage);
            imagedestroy($imageResource);
        }
        return $result;
    }