Modif url
This commit is contained in:
parent
ece421c39c
commit
e94ccf41d3
|
@ -10,8 +10,11 @@ use Meoran\Images\Model\Image;
|
||||||
class ImagesController extends BaseController
|
class ImagesController extends BaseController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function get($template, $filename)
|
public function get($filename, $template = null)
|
||||||
{
|
{
|
||||||
|
if ($template === null) {
|
||||||
|
$template = 'original';
|
||||||
|
}
|
||||||
switch (strtolower($template)) {
|
switch (strtolower($template)) {
|
||||||
case 'original':
|
case 'original':
|
||||||
return $this->getOriginal($filename);
|
return $this->getOriginal($filename);
|
||||||
|
|
|
@ -5,9 +5,9 @@ namespace Meoran\Images\Model;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||||
use Intervention\Image\Exception\NotReadableException;
|
use Intervention\Image\Exception\NotReadableException;
|
||||||
|
use Intervention\Image\Image as InterventionImage;
|
||||||
use Meoran\Images\Exception\InvalidContent;
|
use Meoran\Images\Exception\InvalidContent;
|
||||||
use Spatie\ImageOptimizer\OptimizerChain;
|
use Spatie\ImageOptimizer\OptimizerChain;
|
||||||
use \Intervention\Image\Image as InterventionImage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Image
|
* Class Image
|
||||||
|
@ -34,7 +34,11 @@ class Image extends Model
|
||||||
|
|
||||||
public function getUrlAttribute()
|
public function getUrlAttribute()
|
||||||
{
|
{
|
||||||
return app('url')->to('/' . config('image.route') . '/original/' . $this->filename);
|
$route = config('image.route');
|
||||||
|
if (empty($route)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return app('url')->to('/' . $route . '/' . $this->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function boot()
|
protected static function boot()
|
||||||
|
@ -101,7 +105,8 @@ class Image extends Model
|
||||||
$this->attributes['filename'] = $value;
|
$this->attributes['filename'] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fileExist() {
|
public function fileExist()
|
||||||
|
{
|
||||||
return is_file($this->getPath());
|
return is_file($this->getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +173,8 @@ class Image extends Model
|
||||||
* @param $relationName
|
* @param $relationName
|
||||||
* @return MorphToMany
|
* @return MorphToMany
|
||||||
*/
|
*/
|
||||||
public static function createRelation(Model $class, $relationName) {
|
public static function createRelation(Model $class, $relationName)
|
||||||
|
{
|
||||||
|
|
||||||
$instance = $class->newRelatedInstance(self::class);
|
$instance = $class->newRelatedInstance(self::class);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ImagesServiceProvider extends ServiceProvider
|
||||||
'as' => 'uploadImage', 'uses' => '\Meoran\Images\Http\Controllers\ImagesController@upload'
|
'as' => 'uploadImage', 'uses' => '\Meoran\Images\Http\Controllers\ImagesController@upload'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->app->get('images/{template}/{filename}', [
|
$this->app->get('images/{filename}[/{template}]', [
|
||||||
'as' => 'getPicture', 'uses' => '\Meoran\Images\Http\Controllers\ImagesController@get'
|
'as' => 'getPicture', 'uses' => '\Meoran\Images\Http\Controllers\ImagesController@get'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue