SOLVED: Can’t select image (Media library in builder) [2.4 beta]

Browser: Brave V192.140
OS: Windows 11 and Linux Mint (tested in both OS)
URL: LocalHost v 10.1.1 with “Local by Flywheel”
New install with current Wordpress and no plugins/PHP/CSS…

Simple page layout:
Section
Container
Image

When selecting the image we can’t chose image with the “Select Image” option (no response)

This is with Bricks-2.4-Beta

Regards,

Ducktape

1 Like

Hi,
Thanks so much for your report!

I reproduced the issue and added it to our bug tracker.
We’ll update this thread once it’s fixed.

Best regards,
timmse

1 Like

And it was going so well :slight_smile:

main.min.js?ver=1784166126:21 TypeError: this.activateMode is not a function
at media-views.min.js?ver=7.0.1:2:59731
at Lt (control-code.js:9:4794)
at $n.bs (control-code.js:9:40130)
at n._createModes (media-views.min.js?ver=7.0.1:2:59691)
at n.initialize (media-views.min.js?ver=7.0.1:2:59100)
at n.initialize (media-views.min.js?ver=7.0.1:2:79900)
at n.initialize (media-views.min.js?ver=7.0.1:2:73552)
at h.View (backbone.min.js?ver=1.6.1:2:14879)
at n.constructor (wp-backbone.min.js?ver=7.0.1:2:2602)
at n.constructor (media-views.min.js?ver=7.0.1:2:107207)
(anonymous) @ main.min.js?ver=1784166126:21
d @ main.min.js?ver=1784166126:21
c @ main.min.js?ver=1784166126:21
u @ main.min.js?ver=1784166126:21
n @ main.min.js?ver=1784166126:53

And it was going so well :slight_smile:

“TypeError: this.activateMode is not a function”

Well, yeah. That’s the bug. What are you trying to tell us?

Nothing really, just supporting that I’m seeing the same thing :slight_smile:

Overall the beta appears to be prrety solid though.

Temporary fix (add in functions.php):slight_smile:

/**

 * Fix: Bricks' bundled lodash (control-code.js) sets window._ = lodash

 * 4.17.21, overwriting WordPress' Underscore 1.13.8. Lodash lacks

 * _.each thisArg, _.any, _.contains, etc. that WP media scripts need.

 *

 * Intercepts window._ assignment and discards lodash to preserve

 * Underscore. Bricks' internal modules use webpack require() for

 * lodash, not window._, so this is safe.

 *

 * @see https://stackoverflow.com/questions/63672622

 */

add_action( 'wp_enqueue_scripts', function () {

if ( ! bricks_is_builder_main() ) return;

wp_add_inline_script( 'bricks-builder', '

    var _prev = window._;

    Object.defineProperty( window, "_", {

        set: function( v ) {

            if ( v && typeof v.each === "function" && v.each.length === 2 ) {

                return;

            }

            _prev = v;

        },

        get: function() { return _prev; },

        configurable: true, enumerable: true

    } );

    ' );

}, 11 );
1 Like

Hi Atom360,

Thank you for the patch all is working fine :wink:

Regards,

Ducktape

Thank you all for your support

Ducktape

We’ve addressed this in Bricks 2.4-beta2 (beta release), now available for manual download from your Bricks account.

Please read the changelog entry before testing, and let us know if you experience any issues. Note: beta builds are not recommended for production sites.

Good to see this was tracked down and fixed in beta2. The temporary functions.php workaround was a useful bridge, but for anyone testing now it probably makes sense to remove that patch first and verify the fix with a clean 2.4-beta2 setup.

If the media library works normally there, that also helps confirm the lodash/Underscore conflict was indeed the root cause.