nouveau fichier : SRC/app/Http/Controllers/ImageController.php
modifié : SRC/app/Http/routes.php modifié : SRC/composer.json modifié : SRC/composer.lock modifié : SRC/config/app.php modifié : SRC/resources/views/backend/ref_listeoeuvres.blade.php
This commit is contained in:
parent
40dae8987b
commit
091c3cbdd7
56
SRC/app/Http/Controllers/ImageController.php
Normal file
56
SRC/app/Http/Controllers/ImageController.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Response;
|
||||
use Cache;
|
||||
use Image;
|
||||
|
||||
class ImageController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getImage($size,$url)
|
||||
{
|
||||
$size = htmlspecialchars($size);
|
||||
$url = htmlspecialchars($url);
|
||||
$key = $size.$url;
|
||||
if (Cache::has($key))
|
||||
{
|
||||
//On recupere notre image en cache
|
||||
$r = Cache::get($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
// recup image sur le serveur
|
||||
$ch = curl_init();// set url
|
||||
curl_setopt($ch, CURLOPT_URL, "http://www.augustins.org/documents/10180/156407/".$url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$content = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
//redimensionnement
|
||||
$img = Image::make($content)->resize($size, $size, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
|
||||
$r = $img->response('jpg');
|
||||
|
||||
//Met en cache l'image avec son header pendant 2 semaine sur le serveur
|
||||
Cache::add($key, $r, 10080*2 );
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
}
|
@ -18,6 +18,9 @@ Route::get('changerref/{id}', 'HomeController@changerRef');
|
||||
Route::get('api/searchRef/{reg?}', 'APIController@refByName');
|
||||
Route::get('api/searchOeuvres', 'APIController@searchOeuvres');
|
||||
|
||||
//API FOR IMAGE RESIZE
|
||||
Route::get('/image/{size}/{url}', 'ImageController@getImage');
|
||||
|
||||
|
||||
// LOGIN RESET
|
||||
Route::get('password/reset/{token}', array(
|
||||
@ -69,4 +72,4 @@ Route::group(['middleware' => 'ifAdmin'], function ()
|
||||
Route::get('admin/updateUser/{id}', 'AdminController@updateUser');
|
||||
Route::get('admin/logAs/{id}', 'AdminController@logAs');
|
||||
Route::get('logout', 'LoginController@logout');
|
||||
});
|
||||
});
|
||||
|
@ -5,7 +5,8 @@
|
||||
"license": "MIT",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"laravel/framework": "5.0.*"
|
||||
"laravel/framework": "5.0.*",
|
||||
"intervention/image": "~2.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0",
|
||||
|
58
SRC/composer.lock
generated
58
SRC/composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "24c3946acc997e3f3eca7fc5c99585b2",
|
||||
"hash": "6c08ae99a1a7676a1c006b9be992507a",
|
||||
"packages": [
|
||||
{
|
||||
"name": "classpreloader/classpreloader",
|
||||
@ -222,6 +222,62 @@
|
||||
],
|
||||
"time": "2014-12-20 21:24:13"
|
||||
},
|
||||
{
|
||||
"name": "intervention/image",
|
||||
"version": "2.1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Intervention/image.git",
|
||||
"reference": "572806fd083b622dd430d76c34564459596fef2a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Intervention/image/zipball/572806fd083b622dd430d76c34564459596fef2a",
|
||||
"reference": "572806fd083b622dd430d76c34564459596fef2a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-fileinfo": "*",
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.2",
|
||||
"phpunit/phpunit": "3.*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gd": "to use GD library based image processing.",
|
||||
"ext-imagick": "to use Imagick based image processing.",
|
||||
"intervention/imagecache": "Caching extension for the Intervention Image library"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Intervention\\Image\\": "src/Intervention/Image"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Oliver Vogel",
|
||||
"email": "oliver@olivervogel.net",
|
||||
"homepage": "http://olivervogel.net/"
|
||||
}
|
||||
],
|
||||
"description": "Image handling and manipulation library with support for Laravel integration",
|
||||
"homepage": "http://image.intervention.io/",
|
||||
"keywords": [
|
||||
"gd",
|
||||
"image",
|
||||
"imagick",
|
||||
"laravel",
|
||||
"thumbnail",
|
||||
"watermark"
|
||||
],
|
||||
"time": "2015-03-09 13:03:15"
|
||||
},
|
||||
{
|
||||
"name": "ircmaxell/password-compat",
|
||||
"version": "v1.0.4",
|
||||
|
@ -144,6 +144,8 @@ return [
|
||||
'App\Providers\ConfigServiceProvider',
|
||||
'App\Providers\EventServiceProvider',
|
||||
'App\Providers\RouteServiceProvider',
|
||||
|
||||
'Intervention\Image\ImageServiceProvider'
|
||||
|
||||
],
|
||||
|
||||
@ -192,6 +194,7 @@ return [
|
||||
'URL' => 'Illuminate\Support\Facades\URL',
|
||||
'Validator' => 'Illuminate\Support\Facades\Validator',
|
||||
'View' => 'Illuminate\Support\Facades\View',
|
||||
'Image' => 'Intervention\Image\Facades\Image',
|
||||
|
||||
],
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
<legend>Résultat de ma recherche</legend>
|
||||
<select multiple="multiple" class="multiple" id="toadd" name="toadd[]">
|
||||
@foreach($oeuvres as $oeuvre)
|
||||
<option data-img-src='http://www.augustins.org/documents/10180/156407/{{$oeuvre->image}}' value='{{$oeuvre->id}}'></option>
|
||||
<option data-img-src='/image/200/{{$oeuvre->image}}' value='{{$oeuvre->id}}'></option>
|
||||
@endforeach
|
||||
</select>
|
||||
<div class="text-center">
|
||||
{!! $oeuvres->render() !!}
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Ajouter à la liste courante</button>
|
||||
<button type="submit" class="btn btn-primary">Ajouter à la liste courante</button>
|
||||
|
Reference in New Issue
Block a user