File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 4040 * [ Resize] ( #resize )
4141 * [ WaterMark] ( #watermark )
4242 * [ Compress] ( #compress )
43- * [ Get Image Size] ( #get-image-size )
43+ * [ Get External Image Size] ( #get-external-image-size )
44+ * [ Get Uploaded Image Size] ( #get-uploaded-image-size )
4445 * [ Get Mime Type] ( #get-mime-type )
4546 * [ Not Empty] ( #not-empty )
4647 * [ Is Empty] ( #is-empty )
@@ -540,7 +541,7 @@ File::name('avatar')
540541 });
541542```
542543
543- ### Get Image Size
544+ ### Get External Image Size
544545- Takes one param as ` string `
545546 - Return an ` array ` \| ` null `
546547
@@ -553,6 +554,19 @@ File::getImageSize('full_source_path')
553554]
554555```
555556
557+ ### Get Uploaded Image Size
558+ - Takes one param as ` string `
559+ - Return an ` array ` \| ` null `
560+
561+ ```
562+ File::imageSize('name_of_uploaded_file')
563+
564+ [
565+ ["height"] => int(4209)
566+ ["width"] => int(3368)
567+ ]
568+ ```
569+
556570### Get Mime Type
557571- Takes one param as ` string `
558572 - Return ` string ` \| ` bool ` . ` false ` on error.
Original file line number Diff line number Diff line change @@ -137,6 +137,31 @@ public function filter(...$filter)
137137
138138 return $ this ;
139139 }
140+
141+ /**
142+ * Uploaded Image Size
143+ *
144+ * @param mixed $name
145+ *
146+ * @return array
147+ * [width, height]
148+ */
149+ public function imageSize (string $ name = null )
150+ {
151+ $ instance = $ this ->name ($ name );
152+
153+ // loop through to get temporary uploaded file data
154+ if (!empty ($ instance ->files [$ name ]) && is_array ($ instance ->files [$ name ])){
155+ foreach ($ instance ->files [$ name ] as $ item ){
156+ return $ item ->imageSize ();
157+ }
158+ }
159+
160+ return [
161+ 'width ' => null ,
162+ 'height ' => null
163+ ];
164+ }
140165
141166 /**
142167 * Get Image Attributes
You can’t perform that action at this time.
0 commit comments