@@ -10,14 +10,13 @@ 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
- $ image_file = $ custom ['image ' ] ?? request ()->file ($ fieldname ); // Retriving Image File
16
+ $ image_file = $ custom ['image ' ] ?? request ()->file ($ fieldname ); // Retriving Image File
17
17
$ extension = $ this ->image_info ($ image_file )->extension ; //Retriving Image extension
18
18
$ imageStoreNameOnly = $ this ->image_info ($ image_file )->imageStoreNameOnly ; //Making Image Store name
19
19
20
-
21
20
/* ------------------------------------------------------------------- */
22
21
23
22
/* ----------------------------------------Parent Image Upload----------------------------------------- */
@@ -30,7 +29,7 @@ public function makeThumbnail($fieldname = 'image', $custom = [])
30
29
if ($ thumbnails ) {
31
30
/* -----------------------------------------Custom Thumbnails------------------------------------------------- */
32
31
$ this ->makeCustomThumbnails ($ image_file , $ imageStoreNameOnly , $ extension , $ storage , $ thumbnails );
33
- /* -------------------------------------------------------------------------------------------------- */
32
+ /* -------------------------------------------------------------------------------------------------- */
34
33
} else {
35
34
/* ---------------------------------------Default Thumbnails--------------------------------------- */
36
35
$ this ->makeDefaultThumbnails ($ image_file , $ extension , $ imageStoreNameOnly );
@@ -47,14 +46,14 @@ private function makeImg($image_file, $name, $location, $width, $height, $qualit
47
46
$ img = Image::cache (function ($ cached_img ) use ($ image_file , $ width , $ height ) {
48
47
return $ cached_img ->make ($ image_file ->getRealPath ())->fit ($ width , $ height );
49
48
}, config ('thumbnail.image_cached_time ' , 10 ), true ); //Storing Thumbnail
50
- $ img ->save (public_path ('storage/ ' . $ image ), $ quality ); //Storing Thumbnail
49
+ $ img ->save (public_path ('storage/ ' . $ image ), $ quality ); //Storing Thumbnail
51
50
}
52
51
53
52
// Make Custom Thumbnail
54
53
private function makeCustomThumbnails ($ image_file , $ imageStoreNameOnly , $ extension , $ storage , $ thumbnails )
55
54
{
56
55
foreach ($ thumbnails as $ thumbnail ) {
57
- $ customthumbnail = $ imageStoreNameOnly . '- ' . str_replace ('- ' , '' , $ thumbnail ['thumbnail-name ' ]) . '. ' . $ extension ; // Making Thumbnail Name
56
+ $ customthumbnail = $ imageStoreNameOnly. '- ' . str_replace ('- ' , '' , $ thumbnail ['thumbnail-name ' ]). '. ' . $ extension ; // Making Thumbnail Name
58
57
$ this ->makeImg (
59
58
$ image_file ,
60
59
$ customthumbnail ,
@@ -71,10 +70,10 @@ private function makeDefaultThumbnails($image_file, $extension, $imageStoreNameO
71
70
{
72
71
/* --------------------- Thumbnail Info---------------------------------------- */
73
72
//small thumbnail name
74
- $ smallthumbnail = $ imageStoreNameOnly . '-small ' . '. ' . $ extension ; // Making Thumbnail Name
73
+ $ smallthumbnail = $ imageStoreNameOnly. '-small ' . '. ' . $ extension ; // Making Thumbnail Name
75
74
76
75
//medium thumbnail name
77
- $ mediumthumbnail = $ imageStoreNameOnly . '-medium ' . '. ' . $ extension ; // Making Thumbnail Name
76
+ $ mediumthumbnail = $ imageStoreNameOnly. '-medium ' . '. ' . $ extension ; // Making Thumbnail Name
78
77
79
78
// Medium Thumbnail
80
79
$ this ->makeImg (
@@ -106,15 +105,16 @@ private function image_info($image_file)
106
105
$ raw_filename = pathinfo ($ filenamewithextension , PATHINFO_FILENAME ); //Retriving Image Raw Filename only
107
106
$ filename = str_replace (['- ' , ' ' ], '' , $ raw_filename ); // Retrive Filename
108
107
$ extension = $ image_file ->getClientOriginalExtension (); //Retriving Image extension
109
- $ imageStoreNameOnly = $ filename . '- ' . time (); //Making Image Store name
110
- $ 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
111
110
112
111
$ image_info ['filenamewithextension ' ] = $ filenamewithextension ;
113
112
$ image_info ['raw_filename ' ] = $ raw_filename ;
114
113
$ image_info ['filename ' ] = $ filename ;
115
114
$ image_info ['extension ' ] = $ extension ;
116
115
$ image_info ['imageStoreNameOnly ' ] = $ imageStoreNameOnly ;
117
116
$ image_info ['imageStoreName ' ] = $ imageStoreName ;
117
+
118
118
return json_decode (json_encode ($ image_info ));
119
119
}
120
120
@@ -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
@@ -164,21 +164,21 @@ public function imageDetail($fieldname = 'image', $size = null)
164
164
$ image = $ this ->$ fieldname ;
165
165
$ path = explode ('/ ' , $ image );
166
166
$ extension = \File::extension ($ image );
167
- $ name = basename ($ image , '. ' . $ extension );
168
- $ image_fullname = isset ($ size ) ? $ name . '- ' . (string ) $ size . '. ' . $ extension : $ name . '. ' . $ extension ;
167
+ $ name = basename ($ image , '. ' . $ extension );
168
+ $ image_fullname = isset ($ size ) ? $ name. '- ' . (string ) $ size. '. ' . $ extension : $ name. '. ' . $ extension ;
169
169
array_pop ($ path );
170
170
$ location = implode ('/ ' , $ path );
171
- $ path = 'storage/ ' . $ location . '/ ' . $ image_fullname ;
172
- $ image_files = File::files (public_path ('storage/ ' . $ location ));
171
+ $ path = 'storage/ ' . $ location. '/ ' . $ image_fullname ;
172
+ $ image_files = File::files (public_path ('storage/ ' . $ location ));
173
173
$ images_property = $ this ->imageProperty ($ image_files , $ name );
174
174
$ image_detail = [
175
175
'image ' => $ image ,
176
176
'name ' => $ name ,
177
177
'fullname ' => $ image_fullname ,
178
178
'extension ' => $ extension ,
179
179
'path ' => $ path ,
180
- 'directory ' => public_path ('storage/ ' . $ location ),
181
- 'location ' => public_path ('storage/ ' . $ image ),
180
+ 'directory ' => public_path ('storage/ ' . $ location ),
181
+ 'location ' => public_path ('storage/ ' . $ image ),
182
182
'property ' => $ images_property ,
183
183
];
184
184
@@ -188,13 +188,12 @@ public function imageDetail($fieldname = 'image', $size = null)
188
188
// Image Property
189
189
private function imageProperty ($ image_files , $ parent_name )
190
190
{
191
-
192
191
$ images_property = [];
193
192
$ thumbnails_property = [];
194
193
$ thumbnail_count = 0 ;
195
194
foreach ($ image_files as $ image ) {
196
195
$ image_partition = explode ('- ' , basename ($ image ));
197
- $ parent_thumbnail_name = $ image_partition [0 ] . '- ' . $ image_partition [1 ];
196
+ $ parent_thumbnail_name = $ image_partition [0 ]. '- ' . $ image_partition [1 ];
198
197
if ($ parent_name == $ parent_thumbnail_name ) {
199
198
$ thumbnail_count ++;
200
199
$ thumbnail_exists = $ this ->imageExists ($ image );
0 commit comments