Applies all changes with the image and save it
@param int $imageId Edit image identifier
@return array
762421
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;
    }
991798
public function saveOriginalImageToCache($fileID)
    {
        Storage::disk($this->cache_disk)->put($this->generateCacheFilePath($fileID), $this->getOriginalImageFile());
    }
398186
public function edit(string $id)
    {
        $entity = $this->Dblists->get($id);
        if ($this->request->is(['patch', 'post', 'put'])) {
            $entity = $this->Dblists->patchEntity($entity, (array)$this->request->getData());
            if ($this->Dblists->save($entity)) {
                $this->Flash->success('The database list has been saved.');

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error('The database list could not be saved. Please, try again.');
        }

        $this->set(compact('entity'));
        $this->set('_serialize', ['entity']);
    }
929770
public function updateDefaultPicture($pictureId)
    {
    	if ($pictureId) {
        	$this->pictures()->update(['default' => false]);
        	$this->pictures()->where('id', $pictureId)->update(['default' => true]);
    	}
    }
98937
public function rename($fileID, $name)
    {
        $data = [
            'file_id' => $fileID,
            'name'    => $name
        ];

        return $this->post('files/rename', $data, \true);
    }
700158
public function update($productId, ProductImage &$productImage)
    {
        $data = $productImage->exportData();
        $endpoint = '/admin/products/'.$productId.'/images/'.$productImage->id.'.json';
        $response = $this->request(
            $endpoint, 'PUT', array(
            'image' => $data
            )
        );
        $productImage->setData($response['image']);
    }
946135
public function __async_updateAlt($imageId)
    {
        // @var array $result Result of asynchronous controller
        $result = array('status' => false);
        // @var \samson\activerecord\gallery $image Image to insert into editor
        $image = null;
        //get data from ajax
        $data = json_decode(file_get_contents('php://input'), true);
        //set input value
        $value = trim($data['value']);


        // Getting first field image
        if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)
            ->where('PhotoID', $imageId)->first($image)) {
            // Update value alt
            $image->Description = $value;
            // Save result in datebase
            $image->save();
            // Set success status
            $result['status'] = true;
            // Reduce number of characters to 25
            $result['description'] = utf8_limit_string($value, 25, '...');
            // Return result value
            $result['value'] = $value;
        }

        return $result;
    }
777782
public function edit($id)
    {
        $this->loadModel('Menu.Menus');
        $menu = $this->Menus->get($id);

        if ($this->request->data()) {
            $menu = $this->Menus->patchEntity($menu, $this->request->data(), [
                'fieldList' => [
                    'title',
                    'description',
                    'settings',
                ],
                'validate' => false
            ]);

            if ($this->Menus->save($menu, ['atomic' => true])) {
                $this->Flash->success(__d('menu', 'Menu has been saved!'));
                $this->redirect($this->referer());
            } else {
                $this->Flash->danger(__d('menu', 'Menu could not be saved, please check your information'));
            }
        }

        $this->title(__d('menu', 'Editing Menu'));
        $this->set('menu', $menu);
        $this->Breadcrumb
            ->push('/admin/menu/manage')
            ->push(__d('menu', 'Editing menu {0}', $menu->title), '#');
    }
674862
public function edit(string $id)
    {
        $table = $this->loadModel();

        $entity = $this->fetchEntity($id);

        if ($this->request->is(['patch', 'post', 'put'])) {
            $post_data = (array)$this->request->getData();

            // enable accessibility to associated entity's primary key
            // to avoid associated entity getting flagged as new
            $options = $table instanceof Table ? $table->enablePrimaryKeyAccess() : [];

            $response = $this->persistEntity($entity, $post_data, $options);
            if ($response) {
                $this->saveAssociations($entity, $post_data);

                return $response;
            }
        }

        $this->set('entity', $entity);
        $this->render('CsvMigrations.Common/edit');
        $this->set('_serialize', ['entity']);
    }
1243666
public function edit($id = null)
    {
        $user = $this->Users->get($id, [
            'contain' => []
        ]);

        $user->accessible('role_id', true); // the role_id field should be accessible
        $user->accessible('active', true); // the active field should be accessible

        $roles = $this->Users->Roles->find('list');

        if ($this->request->is(['patch', 'post', 'put'])) {
            $user = $this->Users->patchEntity($user, $this->request->data);
            if ($this->Users->save($user)) {
                $this->Flash->success(__('The user has been saved.'));
                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error(__('The user could not be saved. Please, try again.'));
            }
        }

        $customFields = Hash::normalize(Configure::read('CM.UserFields'));

        $this->set(compact('user', 'roles', 'customFields'));

        $this->render(Configure::read('CM.AdminUserViews.edit'));
    }
33072
public function removeImage($entityId)
    {
        if (!$entityId) {
            return false;
        }

        $delete = '
        UPDATE ' . $this->repository->getClassName() . ' a
        SET a.image = NULL
        WHERE a.id = ' . $entityId . '
        ';
        $q = $this->query($delete);
        $q->execute();
    }
972451
public function get($productId, $productImageId)
    {
        $endpoint = '/admin/products/'.$productId.'/images/'.$productImageId.'.json';
        $response = $this->request($endpoint, 'GET');
        return $this->createObject(ProductImage::class, $response['image']);
    }
1340109
public function edit($id = null) {
		if (!$this->Printer->exists($id)) {
			throw new NotFoundException(__('Invalid printer'));
		}
		if ($this->request->is(array('post', 'put'))) {
			if ($this->Printer->save($this->request->data)) {
				$this->Session->setFlash(__('The printer has been saved.'));
				return $this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The printer could not be saved. Please, try again.'));
			}
		} else {
			$options = array(
				'conditions' => array('Printer.' . $this->Printer->primaryKey => $id),
				'recursive' => -1,
				);
			$this->request->data = $this->Printer->find('first', $options);
		}

		if (empty( $this->request->data['Printer']['output'] ) ) {
			$this->request->data['Printer']['output'] = Configure::read('Printers.output');
		}

		$this->set('drivers', $this->drivers );
		$this->set('driverModels', $this->driver_models);
		$this->set('outputs', $this->outputs);
	}
369224
public function actionUpdate($id)
    {
        $model = Mediafile::findOne($id);
        $message = Module::t('main', 'Changes not saved.');

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            $message = Module::t('main', 'Changes saved!');
        }

        Yii::$app->session->setFlash('mediafileUpdateResult', $message);

        Yii::$app->assetManager->bundles = false;
        return $this->renderAjax('info', [
            'model' => $model,
            'strictThumb' => null,
        ]);
    }
724903
public function get_album_photos($albumid) {
        $albumcontent = $this->googleoauth->get(self::ALBUM_PHOTO_LIST.$albumid);

        return $this->get_photo_details($albumcontent);
    }
1240747
public function fileLookup($fileId) {
		$member = $this->securityContext->getMember();
		if (!$member) {
			return;
		}
		
		$file = File::get()->filter(array('ID' => $fileId, 'OwnerID' => $member->ID))->first();
		if ($file && $file->ID) {
			return array(
				'Title'		=> $file->Title,
				'Link'		=> $file->getAbsoluteURL(),
				'IsImage'	=> $file instanceof Image,
				'ID'		=> $file->ID,
			);
		}
	}
748503
public function deleteImage($productId)
    {
        $productId = (int) $productId;

        if ($productId == 0 || $productId == '') {
            $message = 'Product ID not correct: ' . $productId;
            $this->log($message);
            die(json_encode([
                'status' => 0,
                'msg' => $message
            ]));
        }

        $product = $this->Product->find('all', [
            'conditions' => [
                'Products.id_product' => $productId
            ],
            'contain' => [
                'Images',
                'Manufacturers'
            ]
        ])->first();
        
        $this->Product->changeImage(
            [
                [$productId => 'no-image']
            ]
        );

        $actionLogMessage = __d('admin', 'Image_ID_{0}_from_manufacturer_{1}_was_deleted_successfully_Product_{1}_Manufacturer_{2}.', [
            $product->image->id_image,
            '<b>' . $product->name . '</b>',
            '<b>' . $product->manufacturer->name . '</b>'
        ]);

        $this->Flash->success($actionLogMessage);
        $this->ActionLog->customSave('product_image_deleted', $this->AppAuth->getUserId(), $productId, 'products', $actionLogMessage);

        $this->getRequest()->getSession()->write('highlightedRowId', $productId);

        $this->redirect($this->referer());
    }