Skip Navigation

JavaScript error and Media uploader not working for user Image fields

Resolved

Resolved in: 3.3.7

Topic Tags: Types plugin

Symptoms

Toolset allows you to add custom Image fields to the WordPress user profiles. When users without permission to upload media use such a field, the WordPress Media Uploader doesn’t open and the following JavaScript error is produced:

  • toolset-media-field.prototype.js?ver=3.3.7:140 Uncaught TypeError: wp.media is not a function
    at Toolset.Forms.MediaField.Toolset.Common.MediaField.manageInputSelectorClick (toolset-media-field.prototype.js?ver=3.3.7:140)
    at HTMLButtonElement. (toolset-media-field.prototype.js?ver=3.3.7:58)
    at HTMLDocument.dispatch (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,zxcvbn-async,underscore,wp-util,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-resiz&load[]=able,jquery-ui-draggable,jquery-ui-button,jquery-ui-position,jquery-ui-dialog,jquery-ui-tabs,backbone,jquery-effects-core,jquery&load[]=-effects-size,jquery-effects-scale,jquery-ui-sortable,wp-pointer,quicktags,wp-a11y,wplink,suggest,shortcode&ver=5.1.1:3)
    at HTMLDocument.r.handle (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,zxcvbn-async,underscore,wp-util,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-resiz&load[]=able,jquery-ui-draggable,jquery-ui-button,jquery-ui-position,jquery-ui-dialog,jquery-ui-tabs,backbone,jquery-effects-core,jquery&load[]=-effects-size,jquery-effects-scale,jquery-ui-sortable,wp-pointer,quicktags,wp-a11y,wplink,suggest,shortcode&ver=5.1.1:3)

Workaround

To resolve this issue, you need to allow specific user roles (e.g. Subscribers) to upload files.

Update

In the versions of Types where this issue is fixed, there is a new message on the Custom Field editing screen:

  • “Only the users with proper permissions can use the media uploader”.

This means that, for example, as a Subscriber user, you won’t see the Select image button after the custom user image field.

However, if you install the Access plugin and add the upload_files capability to the Subscriber user role, you will be able to see the Select image button and clicking it will open the Media uploader dialog.

Comments are closed