@@ -10,7 +10,7 @@ discard block |
||
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 |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | private function makeImg($image_file, $name, $location, $width, $height, $quality) |
44 | 44 | { |
45 | 45 | $image = $image_file->storeAs($location, $name, 'public'); // Thumbnail Storage Information |
46 | - $img = Image::cache(function ($cached_img) use ($image_file, $width, $height) { |
|
46 | + $img = Image::cache(function($cached_img) use ($image_file, $width, $height) { |
|
47 | 47 | $baseImage = $cached_img->make($image_file->getRealPath()); |
48 | 48 | if ($config('thumbnail.keep_aspect_ratio')) { |
49 | - return $baseImage->resize($width, $height, function ($constraint) { |
|
49 | + return $baseImage->resize($width, $height, function($constraint) { |
|
50 | 50 | $constraint->aspectRatio(); |
51 | 51 | $constraint->upsize(); |
52 | 52 | }); |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | }, config('thumbnail.image_cached_time', 10), true); //Storing Thumbnail |
58 | - $img->save(public_path('storage/'.$image), $quality); //Storing Thumbnail |
|
58 | + $img->save(public_path('storage/' . $image), $quality); //Storing Thumbnail |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | // Make Custom Thumbnail |
62 | 62 | private function makeCustomThumbnails($image_file, $imageStoreNameOnly, $extension, $storage, $thumbnails) |
63 | 63 | { |
64 | 64 | foreach ($thumbnails as $thumbnail) { |
65 | - $customthumbnail = $imageStoreNameOnly.'-'.str_replace('-', '', $thumbnail['thumbnail-name']).'.'.$extension; // Making Thumbnail Name |
|
65 | + $customthumbnail = $imageStoreNameOnly . '-' . str_replace('-', '', $thumbnail['thumbnail-name']) . '.' . $extension; // Making Thumbnail Name |
|
66 | 66 | $this->makeImg( |
67 | 67 | $image_file, |
68 | 68 | $customthumbnail, |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | { |
80 | 80 | /* --------------------- Thumbnail Info---------------------------------------- */ |
81 | 81 | //small thumbnail name |
82 | - $smallthumbnail = $imageStoreNameOnly.'-small'.'.'.$extension; // Making Thumbnail Name |
|
82 | + $smallthumbnail = $imageStoreNameOnly . '-small' . '.' . $extension; // Making Thumbnail Name |
|
83 | 83 | |
84 | 84 | //medium thumbnail name |
85 | - $mediumthumbnail = $imageStoreNameOnly.'-medium'.'.'.$extension; // Making Thumbnail Name |
|
85 | + $mediumthumbnail = $imageStoreNameOnly . '-medium' . '.' . $extension; // Making Thumbnail Name |
|
86 | 86 | |
87 | 87 | // Medium Thumbnail |
88 | 88 | $this->makeImg( |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | $raw_filename = pathinfo($filenamewithextension, PATHINFO_FILENAME); //Retriving Image Raw Filename only |
115 | 115 | $filename = $this->validImageName($raw_filename); // Retrive Filename |
116 | 116 | $extension = $image_file->getClientOriginalExtension(); //Retriving Image extension |
117 | - $imageStoreNameOnly = $filename.'-'.time(); //Making Image Store name |
|
118 | - $imageStoreName = $filename.'-'.time().'.'.$extension; //Making Image Store name |
|
117 | + $imageStoreNameOnly = $filename . '-' . time(); //Making Image Store name |
|
118 | + $imageStoreName = $filename . '-' . time() . '.' . $extension; //Making Image Store name |
|
119 | 119 | |
120 | 120 | $image_info['filenamewithextension'] = $filenamewithextension; |
121 | 121 | $image_info['raw_filename'] = $raw_filename; |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | ]); |
139 | 139 | |
140 | 140 | |
141 | - $image = Image::cache(function ($cached_img) use ($image_file, $custom) { |
|
141 | + $image = Image::cache(function($cached_img) use ($image_file, $custom) { |
|
142 | 142 | $height = $custom['height'] ?? config('thumbnail.img_height', 800); |
143 | 143 | $width = $custom['width'] ?? config('thumbnail.img_width', 1000); |
144 | 144 | $baseImage = $cached_img->make($image_file->getRealPath()); |
145 | 145 | if (config('thumbnail.keep_aspect_ratio')) { |
146 | - return $baseImage->resize($width, $height, function ($constraint) { |
|
146 | + return $baseImage->resize($width, $height, function($constraint) { |
|
147 | 147 | $constraint->aspectRatio(); |
148 | 148 | $constraint->upsize(); |
149 | 149 | }); //Parent Image Interventing |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | return $baseImage->fit($width, $height); //Parent Image Interventing |
152 | 152 | } |
153 | 153 | }, config('thumbnail.image_cached_time', 10), true); |
154 | - $image->save(public_path('storage/'.$this->$fieldname), $custom['quality'] ?? config('thumbnail.image_quality', 80)); // Parent Image Locating Save |
|
154 | + $image->save(public_path('storage/' . $this->$fieldname), $custom['quality'] ?? config('thumbnail.image_quality', 80)); // Parent Image Locating Save |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | // Thumbnail Path |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | $image = $byLocation ? ($location ?? $this->$fieldname) : $this->$fieldname; // Search By Field or Location |
186 | 186 | $path = explode('/', $image); |
187 | 187 | $extension = \File::extension($image); |
188 | - $name = basename($image, '.'.$extension); |
|
189 | - $image_fullname = isset($size) ? $name.'-'.(string) $size.'.'.$extension : $name.'.'.$extension; |
|
188 | + $name = basename($image, '.' . $extension); |
|
189 | + $image_fullname = isset($size) ? $name . '-' . (string) $size . '.' . $extension : $name . '.' . $extension; |
|
190 | 190 | array_pop($path); |
191 | 191 | $location = implode('/', $path); |
192 | - $path = 'storage/'.$location.'/'.$image_fullname; |
|
193 | - $image_files = File::files(public_path('storage/'.$location)); |
|
192 | + $path = 'storage/' . $location . '/' . $image_fullname; |
|
193 | + $image_files = File::files(public_path('storage/' . $location)); |
|
194 | 194 | $images_property = $this->imageProperty($image_files, $name); |
195 | 195 | $image_detail = [ |
196 | 196 | 'image' => $image, |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | 'fullname' => $image_fullname, |
199 | 199 | 'extension' => $extension, |
200 | 200 | 'path' => $path, |
201 | - 'directory' => public_path('storage/'.$location), |
|
202 | - 'location' => public_path('storage/'.$image), |
|
201 | + 'directory' => public_path('storage/' . $location), |
|
202 | + 'location' => public_path('storage/' . $image), |
|
203 | 203 | 'property' => $images_property, |
204 | 204 | ]; |
205 | 205 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | $image_partition = explode('-', basename($image)); |
221 | 221 | if (isset($image_partition[0]) && isset($image_partition[1])) { |
222 | - $parent_thumbnail_name = $image_partition[0].'-'.$image_partition[1]; |
|
222 | + $parent_thumbnail_name = $image_partition[0] . '-' . $image_partition[1]; |
|
223 | 223 | if ($parent_name == $parent_thumbnail_name) { |
224 | 224 | $thumbnail_count++; |
225 | 225 | $thumbnail_exists = $this->imageExists($image); |
@@ -272,6 +272,6 @@ discard block |
||
272 | 272 | // Valid Image Name |
273 | 273 | private function validImageName($name) |
274 | 274 | { |
275 | - return strtolower(str_replace([' ', '-', '$', '<', '>', '&', '{', '}', '*', '\\', '/', ':'.';', ',', "'", '"'], '_', trim($name))); |
|
275 | + return strtolower(str_replace([' ', '-', '$', '<', '>', '&', '{', '}', '*', '\\', '/', ':' . ';', ',', "'", '"'], '_', trim($name))); |
|
276 | 276 | } |
277 | 277 | } |