[Resolved] Image upload fields are not working on my forms
This support ticket is created 4 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I am trying to: One of my form has stopped working, The image uploads are no longer doing anything.
Link to a page where the issue can be seen: hidden link
I expected to see:
A box to upload images
Instead, I got:
No reaction to my button presses.
there also seems to be an error in the chrome console.
Uncaught TypeError: jQuery(...).geocomplete is not a function
at (index):350
Large-white-BG-extra-transparent-logo-1500x844.png:1 Failed to load resource: net::ERR_CERT_COMMON_NAME_INVALID
4cred_media_manager.min.js:13 Uncaught TypeError: Cannot read property 'model' of undefined
at Toolset.CRED.MediaField.self.setParentId (cred_media_manager.min.js:13)
at Toolset.CRED.MediaField.Toolset.Common.MediaField.manageInputSelectorClick (toolset-media-field-prototype.min.js:4)
at HTMLInputElement.<anonymous> (toolset-media-field-prototype.min.js:1)
at HTMLDocument.dispatch (jquery.js:3)
at HTMLDocument.r.handle (jquery.js:3)
I can see the JS error on that page. It occurs because you appear to have some custom code on the page that references the jQuery geocomplete method before it is defined.
Do you know where the custom code is added?
You should wrap the code inside a callback attached to the DOM ready event by which time the geocomplete method will be available, e.g.
( function( $ ) {
$( document ).ready( function(){
// Your code here
});
})( jQuery );
Thank you for taking a look. I fixed the maps error as per your instructions, many thanks, however the image upload field still seems to be unresponsive. with the other half of the error remaining.
cred_media_manager.min.js:13 Uncaught TypeError: Cannot read property 'model' of undefined
at Toolset.CRED.MediaField.self.setParentId (cred_media_manager.min.js:13)
at Toolset.CRED.MediaField.Toolset.Common.MediaField.manageInputSelectorClick (toolset-media-field-prototype.min.js:4)
at HTMLInputElement.<anonymous> (toolset-media-field-prototype.min.js:1)
at HTMLDocument.dispatch (jquery.js:3)
at HTMLDocument.r.handle (jquery.js:3)
So it looks like it might be a recent theme update which is to blame, I apologise for that, unless there something you think you might be able to do I should probably go bother them.
There are probably some settings available from the plugin or theme, whichever is responsible, that lets you say which JavaScript files it's okay to modify and which not, so I would start by looking for those and see if you are able to blacklist/whitelist different assets.
So I don't know what baring this might have, but none of the optimisation settings in my theme are in effect and I've deleted the site ground optimisation plugin. I have noticed something odd though. I can use the image upload fields if I'm a guest user, but when I'm logged in they break. Does this have any baring on your thoughts?
I've gone back through my themes archives, as far back as nov 2018 back when the site was initially constructed and the button still doesn't work, I think there might be an additional aggravating factor. When I switched back to one of the default WP themes, the upload box changes between when you're logged in vs logged out. With it being a more traditional upload a file button when logged out, and a different big grey box when logged in.
Sorry for spewing info at you, getting a bit desperate.
I've hidden the form in the customer area, and moved it to the following area, hidden link there's a login link in the footer, and a logout link in the NDA user area menu option.
Is it okay if I do some similar checking on your site? (It's a live site, you don't have a staging site?)
The difference between being logged-in or not is expected.
Version 2.4 replaced the custom file uploader with the built-in WP media uploader, but that is only available to logged-in users, and logged-out users don't have any ajax pre-upload, they just select the image file and it gets uploaded at the time the form is submitted.
You can actually disable the WP media library in the form settings (screenshot) and then all users will have the same experience.