當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Image::find方法代碼示例

本文整理匯總了PHP中Image::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Image::find方法的具體用法?PHP Image::find怎麽用?PHP Image::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Image的用法示例。


在下文中一共展示了Image::find方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fire

 /**
  * 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();
 }
開發者ID:SenhorBardell,項目名稱:yol,代碼行數:33,代碼來源:ImagesResizeQueue.php

示例2: deleteAction

 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');
 }
開發者ID:blackskaarj,項目名稱:webgr,代碼行數:60,代碼來源:EditController.php

示例3: show

 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';
 }
開發者ID:Hield,項目名稱:imagesharing,代碼行數:7,代碼來源:images_controller.php

示例4: deAuthorize

 public function deAuthorize($id)
 {
     $image = Image::find($id);
     $image->approved = '0';
     $image->save();
     return Redirect::back()->withInput()->withErrors('Image #' . $id . ' was de-authorized.');
 }
開發者ID:slopedoo,項目名稱:laravel,代碼行數:7,代碼來源:ImagesController.php

示例5: mutateAttribute

 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);
 }
開發者ID:benallfree,項目名稱:laravel-stapler-images,代碼行數:35,代碼來源:AttachmentTrait.php

示例6: display

 /**
  * 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();
     }
 }
開發者ID:Aymerich03,項目名稱:salondebelleza,代碼行數:38,代碼來源:PagesController.php

示例7: destroy

 /**
  * 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');
 }
開發者ID:nsmith7989,項目名稱:spreadsheet,代碼行數:14,代碼來源:ImagesController.php

示例8: flag

 /**
  * 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;
 }
開發者ID:andreuramos,項目名稱:beers,代碼行數:12,代碼來源:Locality.php

示例9: getImageIdAttribute

 public function getImageIdAttribute($value)
 {
     if ($value) {
         $image = Image::find($value);
     } else {
         $image = Image::where('album_id', $this->id)->first();
     }
     return $image ? $image->thumburl : '';
 }
開發者ID:abhishekchaudhary996,項目名稱:auto-generating-gallery,代碼行數:9,代碼來源:Album.php

示例10: destroy

 /**
  * 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');
 }
開發者ID:huuson94,項目名稱:btlwebapp,代碼行數:15,代碼來源:BEImageController.php

示例11: showAction

 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();
 }
開發者ID:josephholsten,項目名稱:swaplady,代碼行數:10,代碼來源:ImageController.php

示例12: update

 /**
  * 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');
     }
 }
開發者ID:jcstrandburg,項目名稱:portfoliowriter,代碼行數:17,代碼來源:ImageController.php

示例13: destroy

 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);
         }
     }
 }
開發者ID:perinikhil,項目名稱:rmm-backend,代碼行數:13,代碼來源:ImageController.php

示例14: __construct

 /**
  * 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']);
     }
 }
開發者ID:patrickespake,項目名稱:go2images,代碼行數:17,代碼來源:ImageSize.php

示例15: destroy

 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);
     }
 }
開發者ID:huuson94,項目名稱:btlwebapp,代碼行數:15,代碼來源:ImagesController.php


注:本文中的Image::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。