/** * Function that gets called on a job * Push::queue('smsSender', $emergency); * * @param $job * @param Emergency $emergency */ public function fire($job, $image) { $s3 = AWS::get('s3'); $image = Image::find($image['id']); if (!$image) { return $job->delete(); } try { $imageUtil = new ImageUtil($image->origin); $galleryImageUtil = new ImageUtil($image->origin); } catch (Exception $e) { return $job->delete(); } $image->thumbnail = $this->uploadImage($s3, $imageUtil->resize2('thumbnail')->getImage()); Log::debug("From queue: Thumbnail: width - {$imageUtil->getWidth()}, height - {$imageUtil->getHeight()}"); Log::debug("Thumbnail URL: {$image->thumbnail}"); $this->preventMemoryLeak(); $image->regular = $this->uploadImage($s3, $galleryImageUtil->resize2('gallery')->getImage()); Log::debug("From queue: Gallery: width - {$galleryImageUtil->getWidth()}, height - {$galleryImageUtil->getHeight()}"); Log::debug("Gallery URL: {$image->regular}"); $this->preventMemoryLeak(); $image->width = $galleryImageUtil->getWidth(); $image->height = $galleryImageUtil->getHeight(); $image->save(); return $job->delete(); }
public function deleteAction() { //TODO check ce_has_image, link is not available but action is callable!! //delete image files (org./copy/thumb) //delete image //delete metadata image -> DB on delete cascade $request = $this->getRequest(); $imageId = intval($this->getRequest()->getParam(Image::COL_ID)); $image = new Image(); //get image_guid //get original extension $rowset = $image->find($imageId); if (count($rowset) == 1) { $rowsetArray = $rowset->toArray(); $imageRow = $rowsetArray[0]; $imGuid = $imageRow[Image::COL_GUID]; $path_parts = pathinfo($imageRow[Image::COL_ORIGINAL_FILENAME]); $imExt = $path_parts['extension']; $filename = $imGuid . '.' . $imExt; $jpgFilename = $imGuid . '.' . 'jpg'; //delete file org/guid+org_ext //delete file copy/guid+.jpg //delete file thumb/guid+.jpg $RELATIVE_UPLOAD_PATH = 'images/originals'; //without pre- and post-slash! $RELATIVE_PATH_IMAGE_THUMBNAILS = 'images/thumbnails'; $RELATIVE_PATH_IMAGE_SHRINKED_WORKING_COPIES = 'images/shrinked_working_copies'; try { $myFile = $RELATIVE_UPLOAD_PATH . '/' . $filename; $fh = fopen($myFile, 'w'); fclose($fh); unlink($myFile); $myFile = $RELATIVE_PATH_IMAGE_SHRINKED_WORKING_COPIES . '/' . $jpgFilename; $fh = fopen($myFile, 'w'); fclose($fh); unlink($myFile); $myFile = $RELATIVE_PATH_IMAGE_THUMBNAILS . '/' . $jpgFilename; $fh = fopen($myFile, 'w'); fclose($fh); unlink($myFile); } catch (Exception $e) { throw new Zend_Exception('Error: can not open file'); } //note: delete of metadata is executed from db $image->delete($image->getAdapter()->quoteInto(Image::COL_ID . ' = ?', $imageId)); //hard delete plus: //delete ce_has_image //delete annotations //delete dots // $imageId = intval($this->getRequest()->getParam(Image::COL_ID)); // $imageResult = $imageTable->find($imageId)->current(); // if($imageResult != null){ // $imageArray = $imageResult->toArray(); // }else{ // $imageArray = array(); // } } $redirect = new Zend_Controller_Action_Helper_Redirector(); $redirect->setGoto('search', 'search', 'image'); }
public function show() { require_once 'models/comment.php'; $image = Image::find(Request::get_id()); $comments = Comment::find_by_image(Request::get_id()); require_once 'views/images/show.php'; }
public function deAuthorize($id) { $image = Image::find($id); $image->approved = '0'; $image->save(); return Redirect::back()->withInput()->withErrors('Image #' . $id . ' was de-authorized.'); }
public function mutateAttribute($key, $value) { preg_match('/(.*)_(image|file)(_la)?$/', $key, $matches); if (count($matches) > 0) { list($match_data, $field_name_prefix, $field_type) = $matches; $la_mode = count($matches) == 4; $field_name = "{$field_name_prefix}_{$field_type}_id"; if (!$this->{$field_name}) { return null; } switch ($field_type) { case 'image': $obj = Image::find($this->{$field_name}); break; case 'file': $obj = Attachment::find($this->{$field_name}); break; default: throw new \Exception("Unrecognized attachment type {$field_type}"); } if (!$obj) { return null; } if ($la_mode) { // Recover image if missing from Laravel Admin $la_fpath = config('laravel-stapler.images.la_path') . "/{$obj->att_file_name}"; if (!file_exists($la_fpath)) { copy($obj->path('admin'), $la_fpath); } return $obj->att_file_name; } return $obj->att; } return parent::mutateAttribute($key, $value); }
/** * Displays a view * * @param mixed What page to display * @return void * @throws NotFoundException When the view file could not be found * or MissingViewException in debug mode. */ public function display() { $imageModel = new Image(); $imagenes = $imageModel->find('all'); $this->set('imagenes', $imagenes); $path = func_get_args(); $count = count($path); if (!$count) { return $this->redirect('/'); } $page = $subpage = $title_for_layout = null; if (!empty($path[0])) { $page = $path[0]; } if (!empty($path[1])) { $subpage = $path[1]; } if (!empty($path[$count - 1])) { $title_for_layout = Inflector::humanize($path[$count - 1]); } $this->set(compact('page', 'subpage', 'title_for_layout')); try { $this->render(implode('/', $path)); } catch (MissingViewException $e) { if (Configure::read('debug')) { throw $e; } throw new NotFoundException(); } }
/** * Remove the specified resource from storage and filesystem. * * @param int $id * @return Response */ public function destroy($id) { $image = Image::find($id); $image->delete(); unlink('uploads/' . $image->filename); Session::flash('message', 'Sucessfully deleted ' . $image->filename); return Redirect::to('images'); }
/** * returns the flag Image Model Object if any * @return null */ public function flag() { $res = DB::table('image')->where('locality_id', $this->id)->first(); if ($res) { return Image::find($res->id); } return null; }
public function getImageIdAttribute($value) { if ($value) { $image = Image::find($value); } else { $image = Image::where('album_id', $this->id)->first(); } return $image ? $image->thumburl : ''; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $image = Image::find($id); $image->delete(); Session::flash('status', true); Session::flash('messages', array('Đã xóa ảnh')); return Redirect::route('admin.image.index'); }
public function showAction() { $this->logger->entering(); $this->logger->info('Load the image by id'); $images = new Image(); $image = $images->find($this->_getParam('id'))->current(); $this->logger->info('Generating response'); $this->getResponse()->setHeader('Content-Type', $image->content_type)->setHeader('Content-Disposition', "inline; filename=\"{$image->name}\"")->setBody($image->data); $this->logger->exiting(); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $this->image = Image::find($id); $this->image->fill(Input::all()); if (!$this->image->valid()) { return Redirect::back()->withInput()->with('errors', $this->image->errors); } else { $this->image->update(); return Redirect::route('projects.index'); } }
public function destroy($projectId, $imageId) { $image = Image::find($imageId); $destinationPath = public_path() . '/uploads/images/'; if ($image->project_id == $projectId) { if (Image::destroy($imageId)) { File::delete($destinationPath . $image->path); return Response::json(['alert' => Messages::$deleteSuccess . 'image']); } else { return Response::json(['alert' => Messages::$deleteFail . 'image'], 404); } } }
/** * Método construtor * @param array $info Atributos do tamanho da imagem */ public function __construct($info = array()) { if (count($info) > 0) { $this->setId($info['id']); $image = Image::find($info['image_id']); $this->setImage($image); $imageType = ImageType::find($info['image_type_id']); $this->setImageType($imageType); $this->setFileName($info['file_name']); $this->setFileContentType($info['file_content_type']); $this->setFileSize($info['file_size']); } }
public function destroy($id) { $image = Image::find($id); if ($image) { $image->album->delete(); $image->delete(); Session::flash('status', 'success'); Session::put('message', array('0' => 'Successed')); return Redirect::to('album?u=' . Session::get('current_user')); } else { Session::flash('status', 'fail'); Session::put('message', array('0' => 'Failed')); return Redirect::to('image/' . $id); } }
public static function add($parameters) { $parameters['userid'] = parent::get_user_logged_in()->id; $parameters['username'] = parent::get_user_logged_in()->username; $image = Image::find($parameters['image']); $comment = new Comment($parameters); $errors = $comment->errors(); if (count($errors) == 0) { $comment->save(); $content['success'] = "Comment was added"; } else { $content['errors'] = $errors; } return $content; }
public static function save($data, $id = null) { if ($id != null) { $image = Image::find($id); } else { $image = new Image(); } $image->path = $data['path']; $image->album_id = $data['album_id']; $image->caption = $data['caption']; $image->post_id = $data['post_id']; $image->count_like = 0; if ($image->save()) { return $image; } }
/** * Get the imageVO by the primary key * * @param int $id * @return imageVO * @todo right exception handling */ public function getImageById($id) { $table = new Image(); try { $rowset = $table->find($id); $dataArray = $rowset->toArray(); return $dataArray; } catch (Exception $e) { return null; } // $image = new imageVO(); // $image->imageId = $dataArray[0][image::colId]; // $image->fishId = $dataArray[0][image::colFishId]; // $image->fileName = $dataArray[0][image::colFilename]; // $image->fileName = $dataArray[0][image::colChecksum]; }
public function destroy($id) { $image = Image::find($id); $result = array(); if (FEUsersHelper::isCurrentUser($image->album->user->id)) { if ($image->album->images->count() > 1) { $image->delete(); echo 'true'; } else { echo 'error'; // this is image is the last one of album. } } else { echo 'false'; } }
/** * вытягиваем все главные картинки * @param array $arItems * @param string $modelName * @return array */ public function getImagesMain($arItems, $modelName) { if ($this->getModule()->className === null) { $imageQuery = Image::find(); } else { $class = $this->getModule()->className; $imageQuery = $class::find(); } $imageQuery->where(['isMain' => 1, 'itemId' => $arItems, 'modelName' => $modelName]); //$imageQuery->orderBy(['isMain' => SORT_DESC, 'id' => SORT_ASC]); $imageRecords = $imageQuery->all(); $imageRecordsAr['items'] = []; $imageRecordsAr['placeholder'] = $this->getModule()->getPlaceHolder(); foreach ($imageRecords as $value) { $imageRecordsAr['items'][$value->itemId] = $value; } return $imageRecordsAr; }
public function getDummyPortrait() { $dummyName = $this->stat('dummy_image'); $uploadPath = $this->stat('upload_path'); $uploadFolder = Folder::find_or_make($uploadPath); $dummyPic = Image::find(join('/', [$uploadPath, $dummyName])); if (!$dummyPic) { //create it $defaultDummy = join('/', [BASE_PATH, $this->stat('default_dummy')]); $assetsDummy = join('/', [BASE_PATH, 'assets', $uploadPath, $dummyName]); if (copy($defaultDummy, $assetsDummy)) { $dummyPic = Image::create(); $dummyPic->setFilename(join('/', [$uploadFolder->getRelativePath(), $dummyName])); $dummyPic->ParentID = $uploadFolder->ID; $dummyPic->write(); } } return $dummyPic; }
public function action_remove() { if (Input::has('image_id') && Input::has('listing_id') && Session::has('id')) { $account = Account::find(Session::get('id')); $image = Image::find(Input::get('image_id')); $listing = Listing::find(Input::get('listing_id')); $location = Location::find($listing->location_id); $owner = Account::find($location->account_id); if ($account && $image && $listing && $location && $owner) { if ($account->id == $owner->id) { $image->delete(); } else { die('logged in user does not match image owner'); } } else { die('class unable to instantiat, wrong id somehwere'); } } else { die('missing input'); } }
/** * Метод добавления одной фотографии: * * @param Image $image - инстанс изображения * @param mixed $imageData - POST-массив данных * @param Block $gallery - инстанс галереи * * @return void **/ private function _addImage(Image $image, array $imageData, Block $gallery) { try { $transaction = Yii::app()->db->beginTransaction(); $image->setAttributes($imageData); // Определяем следующий порядковый номер $criteria = new CDbCriteria(); $criteria->select = new CDbExpression('MAX(sort) as sort'); $max = $image->find($criteria); $image->sort = $max->sort + 10; $gallery->addImage($image); if ($image->save()) { $transaction->commit(); if (Yii::app()->getRequest()->getPost('ajax') === null) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('ClassroomModule.classroom', 'Изображение добавлено!')); $this->redirect(array('/classroom/imageBackend/images', 'id' => $gallery->id)); } } } catch (Exception $e) { $transaction->rollback(); Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, $e->getMessage()); } }
<?php if (empty($_GET['restaurant_id'])) { header('Location: index.php'); } else { require_once '../lib/Restaurant.class.php'; require_once '../lib/User.class.php'; require_once '../lib/Review.class.php'; require_once '../lib/Image.class.php'; require_once '../lib/helper.functions.php'; $restaurant = new Restaurant(); if ($restaurant->find($_GET['restaurant_id'])) { $restaurant_info = $restaurant->get_restaurant_info(); $restaurant_raw_data = $restaurant->get_raw_data(); $image = new Image(); if ($image->find($restaurant_info['restaurant_id'])) { $image_path = $image->get_medium(); } $review = new Review(); if ($review->find_reviews_by_restaurant_id($_GET['restaurant_id'])) { $reviews_data = $review->get_reviews_raw_data(); } } else { header('Location: index.php'); } } require_once '../templates/header.php'; if (isset($_SESSION['login_user_id'])) { $current_user_id = $_SESSION['login_user_id']; } ?>
public function getImgremove($id) { $image = Image::find($id); if ($image == null) { $errors = new \Illuminate\Support\MessageBag(); $errors->add('deleteError', "The image cannot be deleted at this time."); return \Redirect::to('/admin/announcements')->withErrors($errors); } $announcement_id = $image->imageable_id; $image->remove(); return \Redirect::to('admin/announcements/edit/' . $announcement_id); }
<?php use Illuminate\Support\Collection; Route::group(['prefix' => 'admin', 'before' => 'admin|auth.basic'], function () { Route::get('/', ['as' => 'admin.home', function () { return View::make('admin::home'); }]); Route::resource('products', 'AdminProductsController', ['except' => ['show']]); Route::get('terms/{taxonomy}', ['uses' => 'AdminTermsController@index', 'as' => 'admin.terms.index']); Route::get('terms/{taxonomy}/{id}', ['uses' => 'AdminTermsController@show', 'as' => 'admin.terms.show']); Route::post('terms/{taxonomy}', ['uses' => 'AdminTermsController@store', 'as' => 'admin.terms.store']); Route::put('terms/{taxonomy}/{term}', ['uses' => 'AdminTermsController@update', 'as' => 'admin.terms.update']); Route::delete('terms/{taxonomy}/{term}', ['uses' => 'AdminTermsController@destroy', 'as' => 'admin.terms.destroy']); Route::delete('images/{id}', function ($id) { $delete = Image::find($id)->delete(); if (!$delete) { return Response::json(['status' => '0', 'message' => 'Fout bij het verwijderen van de afbeelding.']); } return Response::json(['status' => '1', 'message' => 'De afbeelding is succesvol verwijderd.']); }); });
/** * [get_a_image description] * @param [type] $restaurant_id [description] * @return [type] [description] */ function get_a_image($restaurant_id) { $a_image = new Image(); if ($a_image->find($restaurant_id)) { return $a_image->get_medium(); } return 'images/default.jpg'; }
/** * returns main model image * @return array|null|ActiveRecord */ public function getImage() { $finder = $this->getImagesFinder(['isMain' => 1]); $imageQuery = Image::find()->where($finder); $imageQuery->orderBy(['isMain' => SORT_DESC, 'id' => SORT_ASC]); $img = $imageQuery->one(); if (!$img) { return $this->getModule()->getPlaceHolder(); } return $img; }
public function post_removeimage() { $image_id = URI::Segment(4); $image = Image::find($image_id); $gallery = Image::find($image_id)->gallery()->first(); // delete post $image->delete(); return Redirect::to('user/galleries/view/' . $gallery->id)->with('success', 'The image has been removed from the gallery.'); }
<?php include 'inc.php'; if (!$user->is_admin()) { if (!Validation::own_image($_GET["id"], $user->get_id())) { set_msg("You do not have enough permission."); header("Location: index.php"); exit; } } $image = Image::find($_GET["id"]); if (!$image) { die; } $image->generate_php_header(); echo file_get_contents("images/" . $image->get_path());