⚠ 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

fancybox in "read"



aln
  • profile picture
  • Member

Posted 30 December 2013 - 21:20 PM

Hello all,

 

When I'm using file upload (images) it is being displayed in "fancybox" in the grid and in the add/edit form.

In the "read" form there is no fancybox, just a link that open in a popup.

 

my question: is there a way to enable fancybox for the "read" form so I can see the image and not just a link?

 

Thank you


pbcomput
  • profile picture
  • Member

Posted 31 December 2013 - 06:49 AM

Hello,

 

I am having same issue / question. Does any one know how to achieve it? Please guide. It will be very helpful to me.

 

Thanks.


aln
  • profile picture
  • Member

Posted 31 December 2013 - 09:00 AM

I solved this by extending the grocery crud class and implementing this method:

 

protected function get_upload_file_readonly_input($field_info, $value)

{

if(empty($value))

return '';

 

//Fancybox

$this->load_js_fancybox();

 

$this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery.fancybox.config.js');

 

$unique = mt_rand();

 

$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;

 

$image_class = $is_image ? 'image-thumbnail' : '';

 

$file_url = base_url().$field_info->extras->upload_path.'/'.$value;

 

$input = "<a href='".$file_url."' id='file_$unique' class='open-file";

$input .= $is_image ? " $image_class'><img src='".$file_url."' height='50px'>" : "' target='_blank'>$value";

$input .= "</a> ";

 

return $input;

}