当前位置: 首页>>代码示例>>PHP>>正文


PHP Image::create方法代码示例

本文整理汇总了PHP中Image::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::create方法的具体用法?PHP Image::create怎么用?PHP Image::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Image::$rules);
     if ($validation->passes()) {
         $this->image->create($input);
         return Redirect::route('images.index');
     }
     return Redirect::route('images.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
开发者ID:bailey9005,项目名称:Laravel-For-Landing-Pages,代码行数:15,代码来源:ImagesController.php

示例2: download_lorem_image

 /**
  * Downloads a random image from a public website and installs it into the filesystem
  *
  * @todo This should really be an injectable service. It locks the user into a specific URL.
  * @return Image
  */
 public static function download_lorem_image()
 {
     $url = 'http://lorempixel.com/1024/768?t=' . uniqid();
     $img_filename = "mock-file-" . uniqid() . ".jpeg";
     $img = self::get_mock_folder()->getFullPath() . $img_filename;
     if (ini_get('allow_url_fopen')) {
         file_put_contents($img, file_get_contents($url));
     } else {
         $ch = curl_init($url);
         $fp = fopen($img, 'wb');
         curl_setopt($ch, CURLOPT_FILE, $fp);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_exec($ch);
         curl_close($ch);
         fclose($fp);
     }
     if (!file_exists($img) || !filesize($img)) {
         return false;
     }
     $i = Image::create();
     $i->Filename = self::get_mock_folder()->Filename . $img_filename;
     $i->Title = $img_filename;
     $i->Name = $img_filename;
     $i->ParentID = self::get_mock_folder()->ID;
     $i->write();
     return $i;
 }
开发者ID:helpfulrobot,项目名称:unclecheese-mock-dataobjects,代码行数:33,代码来源:MockDataObject.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // get POST data
     $input = Input::all();
     // set validation rules
     $rules = array('title' => 'required', 'text' => 'required', 'image' => 'required');
     // validate input
     $validation = Validator::make($input, $rules);
     // if validation fails, return the user to the form w/ validation errors
     if ($validation->fails()) {
         return Redirect::back()->withErrors($validation)->withInput();
     } else {
         // create new Post instance
         $post = Post::create(array('title' => $input['title']));
         // create Text instance w/ text body
         $text = Text::create(array('text' => $input['text']));
         // save new Text and associate w/ new post
         $post->text()->save($text);
         // create the new Image
         $image = Image::create(array('url' => $input['image']));
         // save new Text and associate w/ new post
         $post->image()->save($image);
         if (isset($input['tags'])) {
             foreach ($input['tags'] as $tagId) {
                 $tag = Tag::find($tagId);
                 $post->tags()->save($tag);
             }
         }
         // associate the post with the current user
         $post->author()->associate(Auth::user())->save();
         // redirect to newly created post page
         return Redirect::route('post.show', array($post->id));
     }
 }
开发者ID:shruti222patel,项目名称:laravel-model-demo,代码行数:39,代码来源:PostController.php

示例4: add

 public function add()
 {
     if (!$_FILES['image']['name']) {
         return call('pages', 'error');
     }
     $uploadOk = 1;
     // check if image file is a actual image or fake image
     if (isset($_POST['submit'])) {
         $check = getimagesize($_FILES['image']['tmp_name']);
         if ($check !== false) {
             $uploadOk = 1;
         } else {
             $_SESSION['alert'] = "File is not an image.";
             $uploadOk = 0;
         }
     }
     if ($uploadOk == 0) {
         $_SESSION['alert'] = $_SESSION['alert'] . " Sorry, your file was not uploaded.";
     } else {
         $image = \Cloudinary\Uploader::upload($_FILES["image"]["tmp_name"]);
         if (!empty($image)) {
             Image::create($image['public_id'], $image['url'], basename($image['url']));
             $_SESSION['notice'] = "The image " . basename($_FILES['image']['name']) . " has been uploaded.";
         } else {
             $_SESSION['alert'] = "Sorry, there was an error uploading your file. ";
         }
     }
     redirect_to('images', 'index');
 }
开发者ID:Hield,项目名称:imagesharing,代码行数:29,代码来源:images_controller.php

示例5: testHeaderWithSlideshow

 public function testHeaderWithSlideshow()
 {
     $header = Header::create()->withTitle(H1::create()->appendText('Big Top Title ')->appendText(Bold::create()->appendText('in Bold')))->withSubTitle(H2::create()->appendText('Smaller SubTitle ')->appendText(Bold::create()->appendText('in Bold')))->withKicker(H3::create()->appendText('Kicker ')->appendText(Bold::create()->appendText('in Bold')))->withCover(SlideShow::create()->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg'))->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home2.jpg'))->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home3.jpg')));
     $expected = '<header>' . '<figure class="op-slideshow">' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '</figure>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home2.jpg"/>' . '</figure>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home3.jpg"/>' . '</figure>' . '</figure>' . '<h1>Big Top Title <b>in Bold</b></h1>' . '<h2>Smaller SubTitle <b>in Bold</b></h2>' . '<h3 class="op-kicker">Kicker <b>in Bold</b></h3>' . '</header>';
     $rendered = $header->render();
     $this->assertEquals($expected, $rendered);
 }
开发者ID:ActiveWebsite,项目名称:BoojPressPlugins,代码行数:7,代码来源:HeaderTest.php

示例6: testInstantArticleAlmostEmpty

 public function testInstantArticleAlmostEmpty()
 {
     $article = InstantArticle::create()->withCanonicalUrl('')->withHeader(Header::create())->addChild(Paragraph::create()->appendText('Some text to be within a paragraph for testing.'))->addChild(Paragraph::create())->addChild(Paragraph::create()->appendText(" \n \t "))->addChild(Image::create())->addChild(Image::create()->withURL(''))->addChild(SlideShow::create()->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg'))->addImage(Image::create()))->addChild(Ad::create())->addChild(Paragraph::create()->appendText('Other text to be within a second paragraph for testing.'))->addChild(Analytics::create())->withFooter(Footer::create());
     $expected = '<!doctype html>' . '<html>' . '<head>' . '<link rel="canonical" href=""/>' . '<meta charset="utf-8"/>' . '<meta property="op:generator" content="facebook-instant-articles-sdk-php"/>' . '<meta property="op:generator:version" content="' . InstantArticle::CURRENT_VERSION . '"/>' . '<meta property="op:markup_version" content="v1.0"/>' . '</head>' . '<body>' . '<article>' . '<p>Some text to be within a paragraph for testing.</p>' . '<figure class="op-slideshow">' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '</figure>' . '</figure>' . '<p>Other text to be within a second paragraph for testing.</p>' . '</article>' . '</body>' . '</html>';
     $result = $article->render();
     $this->assertEquals($expected, $result);
 }
开发者ID:facebook,项目名称:facebook-instant-articles-sdk-php,代码行数:7,代码来源:InstantArticleTest.php

示例7: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Image::create([]);
     }
 }
开发者ID:quarkmarino,项目名称:escuincles,代码行数:7,代码来源:ImagesTableSeeder.php

示例8: store

 /**
  * Store a newly created resource in storage.
  * POST /adminimages
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Image::$rules);
     if ($validator->fails()) {
         //return Redirect::back()->withErrors($validator)->withInput();
         return Response::json('Upload Error', 400);
     }
     if ($data['code'] !== 0) {
         $building = Building::where('code', '=', $data['code'])->firstOrFail();
         $building_id = $building->id;
     } else {
         $building_id = '0';
     }
     $file = Input::file('file');
     $img_destination = 'public/assets/uploads/img/';
     $extension = $file->getClientOriginalExtension();
     $img_name = rand(11111, 99999) . '.' . $extension;
     $data = array('file' => $img_name, 'building_id' => $building_id);
     //dd($building->id);
     $upload = $file->move($img_destination, $img_name);
     if ($upload) {
         Image::create($data);
         return Response::json($file, 200);
     }
     return Response::json('error', 400);
     //return Redirect::route('admin.images');
 }
开发者ID:syafdia,项目名称:PAS,代码行数:33,代码来源:AdminImagesController.php

示例9: store

 /**
  * Store a newly created resource in storage.
  * POST /brewer
  *
  * @return Response
  */
 public function store()
 {
     if (Input::get('brewer_id')) {
         $brewer = Brewer::find(Input::get('brewer_id'));
     } else {
         $brewer = new Brewer();
     }
     $locality = Locality::find(Input::get('locality_id'));
     if (!$locality) {
         return Redirect::back()->withInput()->withMessage('Invalid Locality');
     }
     $brewer->name = Input::get('name');
     $brewer->url = Input::get('url');
     $brewer->locality_id = $locality->id;
     $brewer->save();
     if (Input::hasFile('logo')) {
         $f = Input::file('logo');
         //Change the image name: s<number_of_service>-<filename>.
         $filename = 'brewer-' . $brewer->id . '-' . $f->getClientOriginalName();
         //Move it to our public folder
         $f->move(public_path() . '/upload/', $filename);
         //This is the path to show it on the web
         $complete_path = '/upload/' . $filename;
         //create the gallery
         $image = array('path' => $complete_path, 'brewer_id' => $brewer->id, 'beer_id' => NULL);
         if ($brewer->logoUrl()) {
             $brewer->logo()->fill($image)->save();
         } else {
             Image::create($image);
         }
     }
     return Redirect::to('/dashboard/brewers');
 }
开发者ID:andreuramos,项目名称:beers,代码行数:39,代码来源:BrewerController.php

示例10: setUp

 /**
  * Setup this test. Creates a 1x1 pixel image filled with white.
  *
  */
 public function setUp()
 {
     if (!Runtime::getInstance()->extensionAvailable('gd')) {
         throw new PrerequisitesNotMetError('GD extension not available');
     }
     $this->image = Image::create(1, 1);
     $this->image->fill($this->image->allocate(new Color('#ffffff')));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:12,代码来源:ImageWriterTest.class.php

示例11: run

 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 100; $i++) {
         $file = $faker->image('public/uploads', 640, 480, 'cats');
         $image = Image::create(array('image' => substr($file, 6), 'thumbnail' => substr($file, 6), 'original_filename' => substr($file, 15)));
     }
 }
开发者ID:bobseven,项目名称:onimage-site,代码行数:8,代码来源:ImageTableSeeder.php

示例12: copyResampled

 public function copyResampled($newWidth, $newHeight)
 {
     $tmp = Image::create($newWidth, $newHeight);
     if (!imagecopyresampled($tmp->h, $this->h, 0, 0, 0, 0, $newWidth, $newHeight, $this->width(), $this->height())) {
         throw new \Exception('imagecopyresampled failed');
     }
     return $tmp;
 }
开发者ID:sd-studio,项目名称:or,代码行数:8,代码来源:image.php

示例13: testRenderWithAudio

 public function testRenderWithAudio()
 {
     $audio = Audio::create()->withURL('http://foo.com/mp3')->withTitle('audio title')->enableMuted()->enableAutoplay();
     $expected_audio = '<audio title="audio title" autoplay="autoplay" muted="muted">' . '<source src="http://foo.com/mp3"/>' . '</audio>';
     $slideshow = SlideShow::create()->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg'))->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home2.jpg'))->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home3.jpg'))->withAudio($audio);
     $expected = '<figure class="op-slideshow">' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '</figure>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home2.jpg"/>' . '</figure>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home3.jpg"/>' . '</figure>' . $expected_audio . '</figure>';
     $rendered = $slideshow->render();
     $this->assertEquals($expected, $rendered);
 }
开发者ID:ActiveWebsite,项目名称:BoojPressPlugins,代码行数:9,代码来源:SlideshowTest.php

示例14: run

 public function run()
 {
     $faker = Faker::create();
     $count = 50;
     $ids = Estate::lists('estate_id');
     $images = read_dir(dir_path('estates'));
     $images = array_values(array_diff($images, ['alien.png']));
     for ($i = 0; $i < $count; $i++) {
         Image::create(['image' => $images[$i], 'estate_id' => $faker->randomElement($ids), 'preview' => $faker->boolean(30)]);
     }
 }
开发者ID:beststrelok,项目名称:petrol,代码行数:11,代码来源:ImageSeeder.php

示例15: run

 public function run()
 {
     DB::table('images')->delete();
     Image::create(array('url' => 'https://pbs.twimg.com/profile_images/378800000607588261/dad9f009a228a78a14f1f4bed0c54f76.png', 'imageable_id' => 1, 'imageable_type' => 'User'));
     Image::create(array('url' => 'https://pbs.twimg.com/profile_images/3047681237/0dae20f6642d52ca86482c7d0d63358c.png', 'imageable_id' => 2, 'imageable_type' => 'User'));
     Image::create(array('url' => '/images/code.png', 'imageable_id' => 1, 'imageable_type' => 'Post'));
     Image::create(array('url' => '/images/code.png', 'imageable_id' => 2, 'imageable_type' => 'Post'));
     Image::create(array('url' => '/images/code.png', 'imageable_id' => 3, 'imageable_type' => 'Post'));
     Image::create(array('url' => '/images/code.png', 'imageable_id' => 4, 'imageable_type' => 'Post'));
     Image::create(array('url' => '/images/code.png', 'imageable_id' => 5, 'imageable_type' => 'Post'));
 }
开发者ID:shruti222patel,项目名称:laravel-model-demo,代码行数:11,代码来源:ImageSeeder.php


注:本文中的Image::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。