# Masonry Image Gallery

**URL:** https://meta.discourse.org/t/masonry-image-gallery/188315
**Category:** Theme component
**Created:** [April 27, 2021, 11:53pm UTC](https://meta.discourse.org/t/masonry-image-gallery/188315 "2021-04-27T23:53:25Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Heddson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heddson/32/96742_2.png) [@Heddson](https://meta.discourse.org/u/Heddson)
#### Post date: [May 2, 2021, 12:14am UTC](https://meta.discourse.org/t/masonry-image-gallery/188315/4 "2021-05-02T00:14:00Z")

</div>

If you have Tiles installed on your site and want to switch to Masonry, you need to change the attribute of the gallery divs to _data-masonry-gallery_ on all of your old gallery posts. That’s if you want your old gallery posts to still render correctly, but don’t want to have both components installed.

Thought I share how you could do that, since I made the switch on my own site. Maybe it can be of some help to someone.

The most obvious way would be to edit the posts manually. That works as long as you don’t have too many posts you need to change, though it could still be a pain to find every posts. But don’t worry, [data explorer](https://meta.discourse.org/t/data-explorer-plugin/32566) to the rescue! Run the following SQL and you’ll get exactly what you need.

```
SELECT user_id, topic_id, post_number
FROM posts p
WHERE raw ~~'%data-theme-tiles%'

```

# 

If there’s too many to edit manually, you could use `rake` to replace every string. To do that, you need to SSH into your sever and run:

```
cd /var/discourse
./launcher enter app
rake posts:remap["data-theme-tiles","data-masonry-gallery"]

```

You can read more about that solution [on this post](https://meta.discourse.org/t/replace-a-string-in-all-posts/48729). Please note the warning from that post about the `rake posts:remap` command:

> [@Replace a string in all posts](https://meta.discourse.org/t/replace-a-string-in-all-posts/48729/1):
>
> > ## ⚠ **WARNING**
> > 
> > We _strongly_ recommend you take a full backup before proceeding, and make _sure_ your string replacement is specific enough to affect _only_ the places you want it to. If this string replacement goes wrong, every post on your site will look broken!

# 

There are most likely also other ways to do it. For example, if you like to you could modify the components code so that it looks for both attributes.

---

_[View the full topic](https://meta.discourse.org/t/masonry-image-gallery/188315)._
