Repository navigation
Fix Masonry Script Issues in BuddyX Theme - #2227
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes critical JavaScript issues preventing the Masonry cascading grid layout from initializing properly in rtMedia galleries within the BuddyX theme. The changes address two root causes: a type mismatch between boolean and string values, and incompatibility with Masonry v4.x API.
Key Changes:
- Updated all masonry layout condition checks to handle both boolean
trueand string"true"values - Enhanced
rtm_masonry_reload()function to detect available Masonry API methods and use appropriate fallback for v4.x compatibility - Applied consistent strict equality comparisons throughout the codebase
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/assets/js/rtMedia.js | Updated masonry layout checks in 5 locations to handle both boolean and string types; refactored rtm_masonry_reload() to support both jQuery bridge and native Masonry v4.x API |
| app/assets/js/rtmedia.min.js | Minified version reflecting all source changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "activity_get_older_updates" === get_action) && | ||
| "undefined" !== typeof rtmedia_masonry_layout && | ||
| "true" === rtmedia_masonry_layout && | ||
| ("true" === rtmedia_masonry_layout || true === rtmedia_masonry_layout) && |
There was a problem hiding this comment.
Can we make a common function that will check both the string "true" and the boolean true value? and use it at all places
|
Unable to PHPCS or SVG scan one or more files due to error running PHPCS/SVG scanner:
The error may be temporary. If the error persists, please contact a human (commit-ID: 443f686). |
Description
This PR fixes issues with the Masonry cascading grid layout not initializing properly on media gallery pages in BuddyX Theme.
Solves #2223
Problem
When Masonry layout is enabled in rtMedia Settings:
$(...).masonry("reload") is not a valid methoderrorsRoot Causes
Boolean/String Type Mismatch: The
rtmedia_masonry_layoutvariable comparison was checking for string"true"but the value could be booleantrue. In JavaScript,true == "true"returnsfalse.Masonry v4.x API: The
reload()method doesn't exist in Masonry v4.x core - it's only added by the jQuery bridge. When the bridge isn't available, the call fails.Solution
rtm_masonry_reload()to check method availability and use native Masonry v4.x methods as fallbackTesting Instructions
Setup
npx grunt build(ornpx grunt terserfor JS only)Test Masonry
masonry("reload")