Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with Laravel: Select Image and use in a simple textfield #438

Open
lon-io opened this issue Jan 8, 2016 · 1 comment
Open

Comments

@lon-io
Copy link

lon-io commented Jan 8, 2016

Hi, I had no trouble integrating FileManager with Laravel for Image upload and with CkEditor. However I could not use it to select an image to use get the url in an input textfield.

FileManager opened in the new window, but on clicking the select button I got the following error in chrome dev tool:
filemanager.min.js:24 Uncaught TypeError: Cannot set property 'value' of null

I checked the following :

  1. https://github.com/simogeo/Filemanager/wiki/How-to-use-the-filemanager-from-a-simple-textfield-%3F
  2. https://github.com/simogeo/Filemanager/wiki/Integrate-the-Filemanager-with-Laravel
  3. https://github.com/simogeo/Filemanager/wiki/How-to-use-the-filemanager-with-colorbox-%3F

I also cloned bestmomo's (https://github.com/bestmomo) example:
https://github.com/bestmomo/laravel5-example
and tried to follow his method but he did not use image selection.

After much searching I realized that the issue was with laravel treating the command:
OpenServerBrowser(url) as a call to a route, in this case(url).

Eventually, I got it to work by changing the line:
parent.document.getElementById($.urlParam('field_name')).value = url;
in filemanager.js:652 to
parent.window.opener.document.getElementById($.urlParam('field_name')).value = url;

I also added the function : self.close() like so:

if($.urlParam('field_name'))
{
parent.window.opener.document.getElementById($.urlParam('field_name')).value = url;
self.close();
}

@simogeo
Copy link
Owner

simogeo commented Jan 9, 2016

Thanks for sharing.

For debugging you can change the lib source to filemanager.js. Chrome dev tool will point you out to the right place.

Would you integrate the proposed fix into the dedicated wiki page ? https://github.com/simogeo/Filemanager/wiki/Integrate-the-Filemanager-with-Laravel
Would be great for laravel users ! thanks

According to you is there another way to make this work with laravel without making any changes to the FM code ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants