I'm reporting a bug where the WordPress media library shows different media depending on whether it's accessed from Bricks Builder or wp-admin. Media uploaded in one context becomes invisible in the other.
The root cause is in WPML_Query_Filter::posts_where_filter() (classes/query-filtering/wpml-query-filter.class.php, around line 144-151):
When the wp.media modal fires wp_ajax_query-attachments, it sends the currently edited post's ID as post_id. WPML resolves that post's language and filters media to only that language. This overrides even wpml_switch_language('all') — there is no official way to bypass it.
Bricks Builder uses the standard wp_enqueue_media() and wp.media modal. It runs on a frontend URL (?bricks=run), so WPML's cookie-based language detection also uses a different cookie than wp-admin, compounding the issue.
The expected behavior is that the media library should show all media regardless of language when opened from a page builder, since media assets are typically shared across languages.
My current workaround is temporarily unsetting $_REQUEST['post_id'] and calling wpml_switch_language('all') on wp_ajax_query-attachments when the referer contains bricks=run. This works but it shouldn't be necessary.
Suggested fix: Either respect wpml_switch_language('all') even when post_id is present in the request, or provide a filter to override the language determination in posts_where_filter for attachment queries.
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
Hello,
WPML will always use the original image that was uploaded in the site's default language and then sync it into other languages.
WPML will handle the media language depending on each admin's language. You can switch the language inside the media library in the top admin bar.
If the media is synced, you will see entries in all languages inside the media library.
You can sync media by going to WPML > Settings > Media Translation. If the option to auto-detect media is enabled, disable it. Then access the manual setup, mark the checkboxes for existing content, and start the process. Note that it might take a while
for WPML to sync the media into all languages.
Now, when it comes to Bricks, we have no influence on how this theme handles the media library. Expected behavior would be that you see in each language the media content that, in fact was synced inside the media library.
An expected behavior of showing all media for all languages in the current language is rather unexpected.
Best regards
Andreas
The topic ‘[Closed] Media library filtered by language inside Bricks Builder due to posts_where_filter hardcoded $_REQUE…’ is closed to new replies.