@@ -22,7 +22,7 @@ |
||
| 22 | 22 | { |
| 23 | 23 | /* Config File Publishing */ |
| 24 | 24 | $this->publishes([ |
| 25 | - __DIR__.'/../config/thumbnail.php' => config_path('thumbnail.php'), |
|
| 25 | + __DIR__ . '/../config/thumbnail.php' => config_path('thumbnail.php'), |
|
| 26 | 26 | ], 'thumbnail-config'); |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -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,17 +43,17 @@ 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 | 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 @@ discard block |
||
| 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 @@ discard block |
||
| 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; |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | $fieldname => $img->storeAs($custom['storage'] ?? config('thumbnail.storage_path', 'uploads'), $imageStoreName, 'public'), // Storing Parent Image |
| 129 | 129 | ]); |
| 130 | 130 | |
| 131 | - $image = Image::cache(function ($cached_img) use ($image_file, $custom) { |
|
| 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,12 +164,12 @@ discard block |
||
| 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, |
@@ -177,8 +177,8 @@ discard block |
||
| 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 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $thumbnail_count = 0; |
| 194 | 194 | foreach ($image_files as $image) { |
| 195 | 195 | $image_partition = explode('-', basename($image)); |
| 196 | - $parent_thumbnail_name = $image_partition[0].'-'.$image_partition[1]; |
|
| 196 | + $parent_thumbnail_name = $image_partition[0] . '-' . $image_partition[1]; |
|
| 197 | 197 | if ($parent_name == $parent_thumbnail_name) { |
| 198 | 198 | $thumbnail_count++; |
| 199 | 199 | $thumbnail_exists = $this->imageExists($image); |