⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Image upload



ezgoen

ezgoen
  • profile picture
  • Member

Posted 29 March 2013 - 08:53 AM

 

Hi folks,

 

Thanks again for grocerycrud

 

There's a buglet - I was wondering why images I uploaded sometimes didn't display

 

here it is 

 

	$is_image = !empty($value) &&
	( substr($value,-4) == '.jpg'
		|| substr($value,-4) == '.png'
		|| substr($value,-5) == '.jpeg'
		|| substr($value,-4) == '.gif'
		|| substr($value,-5) == '.tiff')
		? true : false;		

 

its not checking for uppercase file extension.

 

one of my camera's uses uppercase file extensions.

I'm sure I'm not the only one.

 

 

Hope I got this right - it was just a quick - "OMG - I know why"  followed by a quick search of the code 

 

that got me here - I was manually displaying images in a callback until I found this.

 

 

function _cb_image_callback_column($value, $row){
		$imagepath=dirname(site_url())."/".$row->image_path."/".$row->main_image;
		$result ="<a href=\"$imagepath\" class=\"image-thumbnail\">";
		$result.="<img src=\"$imagepath\" height=\"50px\"/></a>";
		return $result;
	}

 

hope this can be fixed

 

 

Cheers everyone 

 

 

Have a happy easter or a great weekend 

 

 

Ez


ezgoen

ezgoen
  • profile picture
  • Member

Posted 01 April 2013 - 21:45 PM

Hi Again Folks.

 
 
I looked into this and it is indeed a buglet.
application/libraries/grocery_crud.php  (version 1.3)
 

 

protected function change_list_value($field_info, $value = null)
...
line 301 to 307 
-            $is_image = !empty($value) &&
-                    ( substr($value,-4) == '.jpg'
-                            || substr($value,-4) == '.png'
-                            || substr($value,-5) == '.jpeg'
-                            || substr($value,-4) == '.gif'
-                            || substr($value,-5) == '.tiff')
-                            ? true : fal
+    $is_image = !empty($value) &&
+                    (strripos($value,'.jpg',-4) !== False
+                            || strripos($value,'.png',-4) !== False
+                            || strripos($value,'.jpeg',-5) !== False
+                            || strripos($value,'.gif',-4) !== False
+                            || strripos($value,'.tiff',-5) !== False)
+                            ? true : false;


protected function get_upload_file_input($field_info, $value)
line 2353 to 2359
-    $is_image = !empty($value) && 
-                        ( substr($value,-4) == '.jpg' 
-                                || substr($value,-4) == '.png' 
-                                || substr($value,-5) == '.jpeg' 
-                                || substr($value,-4) == '.gif' 
-                                || substr($value,-5) == '.tiff')
-                    ? true : false;
+$is_image = !empty($value) &&
+                    (strripos($value,'.jpg',-4) !== False
+                            || strripos($value,'.png',-4) !== False
+                            || strripos($value,'.jpeg',-5) !== False
+                            || strripos($value,'.gif',-4) !== False
+                            || strripos($value,'.tiff',-5) !== False)
+                            ? true : false;


in assets/grocery_crud/js/jquery_plugins/config/jquery.fileupload.config.js
lines 80 to 85
-                        var is_image = (file_name.substr(-4) == '.jpg'  
-                                   || file_name.substr(-4) == '.png' 
-                                    || file_name.substr(-5) == '.jpeg' 
-                                    || file_name.substr(-4) == '.gif' 
-                                    || file_name.substr(-5) == '.tiff')
-                            ? true : false;
+                var is_image = (file_name.toLowerCase().substr(-4) == '.jpg'  
+                            || file_name.toLowerCase().substr(-4) == '.png' 
+                             || file_name.toLowerCase().substr(-5) == '.jpeg' 
+                            || file_name.toLowerCase().substr(-4) == '.gif' 
+                            || file_name.toLowerCase().substr(-5) == '.tiff')
+                        ? true : false;

 

 

That should do it 
 
Cheers
 
 
Ez