I'm fairly new to grocerycrud
I'm using stable version 1.4.1
I notice in list and edit mode, there is a thumbnail for uploaded image, but just a link in view/read mode for files or image
so I guess I need to edit some code in grocerycrud library
I change this line
protected function get_upload_file_readonly_input($field_info,$value) { $file = $file_url = base_url().$field_info->extras->upload_path.'/'.$value; $value = !empty($value) ? '<a href="'.$file.'" target="_blank">'.$value.'</a>' : ''; return $this->get_readonly_input($field_info, $value); }
to this
protected function get_upload_file_readonly_input($field_info,$value) { $file = $file_url = base_url().$field_info->extras->upload_path.'/'.$value; if(empty($value)) { $value = ""; } else { $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; $file_url = base_url().$field_info->extras->upload_path."/$value"; $file_url_anchor = '<a href="'.$file_url.'"'; if($is_image) { $file_url_anchor .= ' class="image-thumbnail"><img src="'.$file_url.'" height="150px">'; } else { $file_url_anchor .= ' target="_blank">'.$this->character_limiter($value,$this->character_limiter,'...',true); } $file_url_anchor .= '</a>'; $value = $file_url_anchor; } return $this->get_readonly_input($field_info, $value); }
sorry if my English is hard to understand