DocumentationFAQ and troubleshooting

FAQ and troubleshooting

Answers to common questions and fixes for usual problems: an empty grid, jumping images, missing filters, a lightbox that will not open, deep links, frameworks.

Questions #

Does Media Boxes need jQuery or any other library? #

No. It is one custom element with no dependencies, and it needs no build step. Include the stylesheet and the script and write <media-boxes>.

Which browsers does it support? #

The last two versions of Chrome, Edge, Firefox and Safari, with Safari 16.4 or newer. There is no transpiling and there are no polyfills.

What happens without JavaScript? #

The items are plain HTML, so they still show, as a simple CSS grid, and search engines read them. Filters, search, the lightbox and the layouts need JavaScript.

Is the content good for SEO? #

Yes. The grid is Light DOM: your titles, text, links and image alt attributes stay in the page. Nothing is injected from a script file unless you choose to create items from JSON, so for content that should be indexed, write the items as HTML.

Can I use several grids on one page? #

Yes. Give each grid its own id. They share one lightbox and one address hash (separated by |).

Can I use it with React, Vue, Svelte or Angular? #

Yes, since it is a standard custom element. Pass options as a property, not an attribute, and give the element a stable id. Let the framework create the <media-boxes> tag and the items once, and then call grid.refresh() after you change items. If the framework removes the element, call grid.destroy() first. Avoid letting a framework re-render the children of the grid on every update: the engine moves them into its own .mb-grid wrapper.

Does it work in WordPress? #

The engine is the same one the WordPress plugin prints: markup plus a JSON options block. On any WordPress page you can enqueue the two files and paste the markup of a grid into a Custom HTML block.

Where do I change colours and fonts? #

With CSS tokens, in your own stylesheet. See Theming.

How do I translate the labels? #

Use the i18n option. See Accessibility and i18n.

Troubleshooting #

The grid is empty or the items are in one plain column #

  1. Is media-boxes.css loaded? Check the Network panel of your browser for a 404.
  2. Is media-boxes.js loaded, and loaded once? Using both media-boxes.js and media-boxes.esm.js on the same page is an error.
  3. Open the console. A line starting with [media-boxes] explains invalid JSON in data-mb-options.
  4. Are the items direct children of <media-boxes>, with the class mb-item? An extra wrapper <div> around them hides them from the engine.
  5. Check that grid.hasAttribute('data-ready') is true. If it is, the grid is built and the problem is in the CSS of the page.

The grid has no height or sits in a hidden tab #

A grid measures its own width. In a container that is display: none, such as a closed tab or accordion, the width is 0, so nothing is laid out. The engine watches the size and lays out again as soon as the container is shown. If your tab library changes sizes without a resize the engine can see, call grid.layout() after showing it.

Images jump or the layout shifts while loading #

Give every <img> its width and height attributes, or data-mb-width and data-mb-height on the link. The ratio is read from them before the image arrives. Without them the engine measures each image after it loads and lays out again.

The filter pills do not show #

A filter shows the wrong items #

Terms are matched by slug: lowercase, without accents, with other characters turned into -. Food & Drink and food drink are the same term. If two groups should both apply, check filterLogic: it defaults to 'and'.

Search finds nothing #

By default only the title and text are searched. Add other fields: search: { fields: ['title', 'text', 'category', 'author'] }. All typed words must match, in any order.

An item does not open in the lightbox #

A YouTube or Vimeo slide stays empty #

Use the normal page address (https://www.youtube.com/watch?v=..., https://youtu.be/... or https://vimeo.com/...). Videos that forbid embedding cannot play in any lightbox. The player is loaded only when the slide is shown, so check your Content Security Policy allows youtube-nocookie.com or player.vimeo.com in frame-src.

The lightbox opens but its look does not follow my theme #

The lightbox is a child of <body>, outside the grid. Style .mb-lightbox, not media-boxes. See Theming.

My option has no effect #

The grid needs an id. Then #<id>?category=nature selects a term. The q (search) part works only with deepLink: { search: true }. Make sure the item ids are stable.

Items added later do not show #

grid.addItems([...]) adds items. If you appended .mb-item elements by hand, call grid.refresh(). In button, scroll and pages modes, new items past the first chunk stay hidden until they are loaded.

Sorting by price does nothing #

The price shown on a card is only text. Add the number as data, data-price="129" on the item or data: { price: 129 } in JSON, and use price as the sort key.

The page scrolls sideways #

Check that the grid is not inside a container wider than the page and that no item has a fixed width. Items get their width from the engine. Do not set width on .mb-item.

Still stuck? #

Try the Builder to see a working configuration for your idea, and compare it with yours. If you bought Media Boxes on CodeCanyon, ask on the item page, and include a link to the page where the problem shows.