@@ -10,7 +10,7 @@ trait Thumbnail
10
10
{
11
11
public function makeThumbnail ($ fieldname = 'image ' , $ custom = [])
12
12
{
13
- if (!empty (request ()->$ fieldname ) || $ custom ['image ' ]) {
13
+ if (! empty (request ()->$ fieldname ) || $ custom ['image ' ]) {
14
14
/* ------------------------------------------------------------------- */
15
15
16
16
$ image_file = $ custom ['image ' ] ?? request ()->file ($ fieldname ); // Retriving Image File
@@ -29,7 +29,7 @@ public function makeThumbnail($fieldname = 'image', $custom = [])
29
29
if ($ thumbnails ) {
30
30
/* -----------------------------------------Custom Thumbnails------------------------------------------------- */
31
31
$ this ->makeCustomThumbnails ($ image_file , $ imageStoreNameOnly , $ extension , $ storage , $ thumbnails );
32
- /* -------------------------------------------------------------------------------------------------- */
32
+ /* -------------------------------------------------------------------------------------------------- */
33
33
} else {
34
34
/* ---------------------------------------Default Thumbnails--------------------------------------- */
35
35
$ this ->makeDefaultThumbnails ($ image_file , $ extension , $ imageStoreNameOnly );
@@ -46,14 +46,14 @@ private function makeImg($image_file, $name, $location, $width, $height, $qualit
46
46
$ img = Image::cache (function ($ cached_img ) use ($ image_file , $ width , $ height ) {
47
47
return $ cached_img ->make ($ image_file ->getRealPath ())->fit ($ width , $ height );
48
48
}, config ('thumbnail.image_cached_time ' , 10 ), true ); //Storing Thumbnail
49
- $ img ->save (public_path ('storage/ ' . $ image ), $ quality ); //Storing Thumbnail
49
+ $ img ->save (public_path ('storage/ ' . $ image ), $ quality ); //Storing Thumbnail
50
50
}
51
51
52
52
// Make Custom Thumbnail
53
53
private function makeCustomThumbnails ($ image_file , $ imageStoreNameOnly , $ extension , $ storage , $ thumbnails )
54
54
{
55
55
foreach ($ thumbnails as $ thumbnail ) {
56
- $ customthumbnail = $ imageStoreNameOnly . '- ' . str_replace ('- ' , '' , $ thumbnail ['thumbnail-name ' ]) . '. ' . $ extension ; // Making Thumbnail Name
56
+ $ customthumbnail = $ imageStoreNameOnly. '- ' . str_replace ('- ' , '' , $ thumbnail ['thumbnail-name ' ]). '. ' . $ extension ; // Making Thumbnail Name
57
57
$ this ->makeImg (
58
58
$ image_file ,
59
59
$ customthumbnail ,
@@ -70,10 +70,10 @@ private function makeDefaultThumbnails($image_file, $extension, $imageStoreNameO
70
70
{
71
71
/* --------------------- Thumbnail Info---------------------------------------- */
72
72
//small thumbnail name
73
- $ smallthumbnail = $ imageStoreNameOnly . '-small ' . '. ' . $ extension ; // Making Thumbnail Name
73
+ $ smallthumbnail = $ imageStoreNameOnly. '-small ' . '. ' . $ extension ; // Making Thumbnail Name
74
74
75
75
//medium thumbnail name
76
- $ mediumthumbnail = $ imageStoreNameOnly . '-medium ' . '. ' . $ extension ; // Making Thumbnail Name
76
+ $ mediumthumbnail = $ imageStoreNameOnly. '-medium ' . '. ' . $ extension ; // Making Thumbnail Name
77
77
78
78
// Medium Thumbnail
79
79
$ this ->makeImg (
@@ -105,8 +105,8 @@ private function image_info($image_file)
105
105
$ raw_filename = pathinfo ($ filenamewithextension , PATHINFO_FILENAME ); //Retriving Image Raw Filename only
106
106
$ filename = str_replace (['- ' , ' ' ], '' , $ raw_filename ); // Retrive Filename
107
107
$ extension = $ image_file ->getClientOriginalExtension (); //Retriving Image extension
108
- $ imageStoreNameOnly = $ filename . '- ' . time (); //Making Image Store name
109
- $ imageStoreName = $ filename . '- ' . time () . '. ' . $ extension ; //Making Image Store name
108
+ $ imageStoreNameOnly = $ filename. '- ' . time (); //Making Image Store name
109
+ $ imageStoreName = $ filename. '- ' . time (). '. ' . $ extension ; //Making Image Store name
110
110
111
111
$ image_info ['filenamewithextension ' ] = $ filenamewithextension ;
112
112
$ image_info ['raw_filename ' ] = $ raw_filename ;
@@ -131,7 +131,7 @@ public function uploadImage($fieldname = 'image', $custom = [])
131
131
$ image = Image::cache (function ($ cached_img ) use ($ image_file , $ custom ) {
132
132
return $ cached_img ->make ($ image_file ->getRealPath ())->fit ($ custom ['width ' ] ?? config ('thumbnail.img_width ' , 1000 ), $ custom ['height ' ] ?? config ('thumbnail.img_height ' , 800 )); //Parent Image Interventing
133
133
}, config ('thumbnail.image_cached_time ' , 10 ), true );
134
- $ image ->save (public_path ('storage/ ' . $ this ->$ fieldname ), $ custom ['quality ' ] ?? config ('thumbnail.image_quality ' , 80 )); // Parent Image Locating Save
134
+ $ image ->save (public_path ('storage/ ' . $ this ->$ fieldname ), $ custom ['quality ' ] ?? config ('thumbnail.image_quality ' , 80 )); // Parent Image Locating Save
135
135
}
136
136
137
137
// Thumbnail Path
@@ -165,21 +165,21 @@ public function imageDetail($fieldname = 'image', $size = null, $byLocation = fa
165
165
$ image = $ byLocation ? ($ location ?? $ this ->$ fieldname ) : $ this ->$ fieldname ; // Search By Field or Location
166
166
$ path = explode ('/ ' , $ image );
167
167
$ extension = \File::extension ($ image );
168
- $ name = basename ($ image , '. ' . $ extension );
169
- $ image_fullname = isset ($ size ) ? $ name . '- ' . (string ) $ size . '. ' . $ extension : $ name . '. ' . $ extension ;
168
+ $ name = basename ($ image , '. ' . $ extension );
169
+ $ image_fullname = isset ($ size ) ? $ name. '- ' . (string ) $ size. '. ' . $ extension : $ name. '. ' . $ extension ;
170
170
array_pop ($ path );
171
171
$ location = implode ('/ ' , $ path );
172
- $ path = 'storage/ ' . $ location . '/ ' . $ image_fullname ;
173
- $ image_files = File::files (public_path ('storage/ ' . $ location ));
172
+ $ path = 'storage/ ' . $ location. '/ ' . $ image_fullname ;
173
+ $ image_files = File::files (public_path ('storage/ ' . $ location ));
174
174
$ images_property = $ this ->imageProperty ($ image_files , $ name );
175
175
$ image_detail = [
176
176
'image ' => $ image ,
177
177
'name ' => $ name ,
178
178
'fullname ' => $ image_fullname ,
179
179
'extension ' => $ extension ,
180
180
'path ' => $ path ,
181
- 'directory ' => public_path ('storage/ ' . $ location ),
182
- 'location ' => public_path ('storage/ ' . $ image ),
181
+ 'directory ' => public_path ('storage/ ' . $ location ),
182
+ 'location ' => public_path ('storage/ ' . $ image ),
183
183
'property ' => $ images_property ,
184
184
];
185
185
@@ -199,7 +199,7 @@ private function imageProperty($image_files, $parent_name)
199
199
200
200
$ image_partition = explode ('- ' , basename ($ image ));
201
201
if (isset ($ image_partition [0 ]) && isset ($ image_partition [1 ])) {
202
- $ parent_thumbnail_name = $ image_partition [0 ] . '- ' . $ image_partition [1 ];
202
+ $ parent_thumbnail_name = $ image_partition [0 ]. '- ' . $ image_partition [1 ];
203
203
if ($ parent_name == $ parent_thumbnail_name ) {
204
204
$ thumbnail_count ++;
205
205
$ thumbnail_exists = $ this ->imageExists ($ image );
@@ -222,7 +222,6 @@ private function imageProperty($image_files, $parent_name)
222
222
$ images_property ['directory ' ] = $ image ->getPath ();
223
223
$ images_property ['location ' ] = $ image ->getRealPath ();
224
224
} else {
225
- false ;
226
225
}
227
226
}
228
227
}
@@ -253,6 +252,6 @@ public function hardDeleteWithParent($fieldname = 'image'): void
253
252
// Valid Image Name
254
253
private function validImageName ($ name )
255
254
{
256
- return strtolower (str_replace ([' ' , '- ' , '$ ' , '< ' , '> ' , '& ' , '{ ' , '} ' , '* ' , '\\' , '/ ' , ': ' . '; ' , ', ' , "' " , '" ' ], '_ ' , trim ($ name )));
255
+ return strtolower (str_replace ([' ' , '- ' , '$ ' , '< ' , '> ' , '& ' , '{ ' , '} ' , '* ' , '\\' , '/ ' , ': ' . '; ' , ', ' , "' " , '" ' ], '_ ' , trim ($ name )));
257
256
}
258
257
}
0 commit comments