Skip to content

Commit b45e7a3

Browse files
committed
Updated croppa config to newer version
1 parent 95c7f34 commit b45e7a3

File tree

9 files changed

+81
-47
lines changed

9 files changed

+81
-47
lines changed

app/Http/Controllers/Admin/PhotoController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public function getGrid()
3232
{
3333
$photos = Photo::leftJoin('users', 'users.id', '=', 'photos.user_id')
3434
->select([
35-
'photos.id', 'photos.image as image', 'photos.title as title',
36-
'users.name', 'users.id as user_id', 'photos.created_at',
37-
'photos.updated_at'
35+
'photos.id as id', 'photos.image as image', 'photos.title as title',
36+
'users.name', 'users.id as user_id', 'photos.created_at as created_at',
37+
'photos.updated_at as updated_at'
3838
]);
3939

4040
return Datatables::of($photos)

composer.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/app.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,11 @@
146146

147147

148148
/**
149-
* WthatTheTag 3rd party Service Providers
149+
* WthatTheTag and other 3rd party Service Providers
150150
*/
151151
\Bkwld\Croppa\ServiceProvider::class,
152152
\Cviebrock\EloquentSluggable\SluggableServiceProvider::class,
153153
\Yajra\Datatables\DatatablesServiceProvider::class,
154-
155154
],
156155

157156
/*

config/croppa.php

+51-21
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,36 @@
77
*/
88

99
/**
10-
* The directory where source images are found. This is generally where your
11-
* admin stores uploaded files. Can be either an absolute path to your local
12-
* disk (the default) or the name of an IoC binding of a Flysystem instance.
10+
* The directory where source images are found. This is generally where your
11+
* admin stores uploaded files. Can be either an absolute path to your local
12+
* disk (the default) or the name of an IoC binding of a Flysystem instance.
1313
*
1414
* @var string Absolute path in local fileystem
1515
* | string IoC binding name of League\Flysystem\Filesystem
1616
* | string IoC binding name of League\Flysystem\Cached\CachedAdapter
1717
*/
18-
'src_dir' => public_path() . '/uploads',
18+
'src_dir' => public_path().'/uploads',
1919

2020
/**
21-
* The directory where cropped images should be saved. The route to the
21+
* The directory where cropped images should be saved. The route to the
2222
* cropped versions is what should be rendered in your markup; it must be a
2323
* web accessible directory.
2424
*
2525
* @var string Absolute path in local fileystem
2626
* | string IoC binding name of League\Flysystem\Filesystem
2727
* | string IoC binding name of League\Flysystem\Cached\CachedAdapter
2828
*/
29-
'crops_dir' => public_path() . '/uploads',
29+
'crops_dir' => public_path().'/uploads',
3030

3131
/**
32-
* Maximum number of sizes to allow for a particular source file. This is to
33-
* limit scripts from filling up your hard drive with images. Set to falsey or
34-
* comment out to have no limit.
32+
* Maximum number of sizes to allow for a particular source file. This is to
33+
* limit scripts from filling up your hard drive with images. Set to false or
34+
* comment out to have no limit. This is disabled by default because the
35+
* `signing_key` is a better prevention of malicious usage.
3536
*
3637
* @var integer | boolean
3738
*/
38-
'max_crops' => 12,
39+
'max_crops' => false,
3940

4041

4142
/*
@@ -45,21 +46,22 @@
4546
*/
4647

4748
/**
48-
* A regex pattern that compares against the Request path (`Request::path()`)
49-
* to find the image path to the image relative to the crops_dir. This path
50-
* will be used to find the source image in the src_dir. The path component of
51-
* the regex must exist in the first captured subpattern. In other words, in
52-
* the `preg_match` $matches[1].
49+
* A regex pattern that is applied to both the src url passed to
50+
* `Croppa::url()` as well as the crop path received when handling a crop
51+
* request to find the path to the src image relative to both the src_dir
52+
* and crops_dirs. This path will be used to find the source image in the
53+
* src_dir. The path component of the regex must exist in the first captured
54+
* subpattern. In other words, in the `preg_match` $matches[1].
5355
*
5456
* @var string
5557
*/
5658
'path' => 'uploads/(.*)$',
5759

5860
/**
5961
* A regex pattern that works like `path` except it is only used by the
60-
* `Croppa::url($url)` generator function. If the $path url matches, it is
61-
* passed through with no Croppa URL suffixes added. Thus, it will not be
62-
* cropped. This is designed, in particular, for animated gifs which lose
62+
* `Croppa::url($url)` generator function. If the $path url matches, it is
63+
* passed through with no Croppa URL suffixes added. Thus, it will not be
64+
* cropped. This is designed, in particular, for animated gifs which lose
6365
* animation when cropped.
6466
*
6567
* @var string
@@ -73,6 +75,26 @@
7375
// 'url_prefix' => '//'.Request::getHttpHost().'/uploads/', // Local
7476
// 'url_prefix' => 'https://your-bucket.s3.amazonaws.com/uploads/', // S3
7577

78+
/**
79+
* Reject attempts to maliciously create images by signing the generated
80+
* request with a hash based on the request parameters and this signing key.
81+
* Set to 'app.key' to use Laravel's `app.key` config, any other string to use
82+
* THAT as the key, or false to disable.
83+
*
84+
* If you are generating URLs outside of `Croppa::url()`, like the croppa.js
85+
* module, you can disable this feature by setting the `signing_key` config
86+
* to false.
87+
*
88+
* @var string|boolean
89+
*/
90+
'signing_key' => 'app.key',
91+
92+
/**
93+
* The PHP memory limit used by the script to generate thumbnails. Some
94+
* images require a lot of memory to perform the resize, so you may increase
95+
* this memory limit.
96+
*/
97+
'memory_limit' => '128M',
7698

7799
/*
78100
|-----------------------------------------------------------------------------
@@ -81,8 +103,8 @@
81103
*/
82104

83105
/**
84-
* The jpeg quality of generated images. The difference between 100 and 95
85-
* usually cuts the file size in half. Going down to 70 looks ok on photos
106+
* The jpeg quality of generated images. The difference between 100 and 95
107+
* usually cuts the file size in half. Going down to 70 looks ok on photos
86108
* and will reduce filesize by more than another half but on vector files
87109
* there is noticeable aliasing.
88110
*
@@ -91,10 +113,18 @@
91113
'jpeg_quality' => 95,
92114

93115
/**
94-
* Turn on interlacing to make progessive jpegs
116+
* Turn on interlacing to make progessive jpegs.
95117
*
96118
* @var boolean
97119
*/
98120
'interlace' => true,
99121

122+
/**
123+
* If the source image is smaller than the requested size, allow Croppa to
124+
* scale up the image. This will reduce in quality loss.
125+
*
126+
* @var boolean
127+
*/
128+
'upscale' => true,
129+
100130
);

public/js/app.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/js/admin/photos/list.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ $('#admin-photos-table')
2424
serverSide: true,
2525
ajax: $('#admin-photos-table').attr('data-source'), //$(this) is not working
2626
columns: [
27-
{data: 'id'},
27+
{name: 'photos.id', data: 'id'},
2828
{data: 'image', orderable: false, searchable: false},
2929
{data: 'title'},
3030
{data: 'name'},
31-
{data: 'created_at'},
32-
{data: 'updated_at'},
31+
{name:'photos.created_at', data: 'created_at'},
32+
{name: 'photos.updated_at', data: 'updated_at'},
3333
{data: 'action', name: 'action', orderable: false, searchable: false}
3434
],
3535
fnInitComplete: function () {

0 commit comments

Comments
 (0)