# Photos in Gallery Display

> Please note that this is now available as a plugin for easier installation. While you can use this document as a reference, the recommended method to add…

Source: https://tadabase.com/docs/snippets/photos-in-gallery-display  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

> **Warning:** Please note that this is now available as a plugin for easier installation. While you can use this document as a reference, the recommended method to add this functionality is through the plugin installation wizard. Learn more about plugins [here](https://tadabase.com/docs).

![image-slider](https://community.tadabase.io/uploads/default/original/2X/c/cb83ac515aeacc4ae8316397c7228061cc5fa615.gif)

This is a great solution to display pictures stored in an **attachment** field as a gallery view.

**Step 1**

**Inside the HTML section of the custom component, add this code. In my case, field_36 is the attachments field; make sure to update it accordingly.**

```
{{#each records}}
    <div class="col-sm-12 attach-slider-section">
        <div class="row">
            <div class="col-sm-8 attach-slider-wraper">
                <div class="attach-slider-box">
                    <div id="myCarousel" class="carousel slide" data-ride="carousel">
                        <div class="carousel-inner">
                            {{#each obj.field_36}}
                                <div class="item">
                                    <img src="{{url}}" class="attach-slider-image">
                                </div>
                            {{/each}}
                        </div>
                        <div class="col-sm-12">
                            <!-- Indicators -->
                            <ol class="carousel-indicators">
                                {{#each obj.field_36}}
                                    <li data-target="#myCarousel" data-slide-to="0" class="attach-slider-nav" style="background: url('{{url}}');"></li>
                                {{/each}}

                            </ol>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
{{/each}}
```

![Screenshot for “Photos in Gallery Display”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-22_00-16-44.png)

**Step 2**

**Add the following CSS to the custom component.**

```
.attach-slider-section {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
}

.attach-slider-box {
    margin-top: 2rem;
    padding-bottom: 2rem;
}

.attach-slider-image {
    width: 100%;
    height: 627px;
    border-radius: 10px;
}

.carousel-indicators {
    position: relative;
    top: 15px;
    width: 100%;
    padding-left: 0;
    text-align: left;
    margin-left: -15px;
    left: 0;
    margin-bottom: unset;
}

.carousel-indicators .active {
    opacity: unset;
}

.carousel-indicators li {
    border-radius: 9px !important;
    opacity: 0.5;
}

.attach-slider-nav {
    height: 68px !important;
    width: 103px !important;
    background-repeat: no-repeat;
    border-radius: unset !important;
    background-size: cover !important;
}

@media only screen and (max-width: 991px) and (min-width: 768px) {
    .attach-slider-wraper {
        display: block;
        width: 100%;
    }
}
```

![Screenshot for “Photos in Gallery Display”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-22_00-19-23.png)

**Step 3**

**Add the following code to the JavaScript section.**

```
$(document).ready(function() {
    var slidDiv = $(".carousel-inner").find(".item");
    var numInc = 1;

    $(slidDiv).each(function() {
        if (1 == numInc) {
            $(this).addClass("active");
        }

        numInc++;
    });

    var carInd = $(".carousel-indicators").find(".attach-slider-nav");
    var carInc = 0;

    $(carInd).each(function() {
        if (0 == carInc) {
            $(this).addClass("active");
        }

        $(this).attr('data-slide-to', carInc);
        carInc++;
    });
});
```

![Screenshot for “Photos in Gallery Display”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-22_00-22-24.png)

**Original Community Post:**

[A gallery to display photos? - Community Discussions / How Do I - Tadabase Community](https://community.tadabase.io/t/a-gallery-to-display-photos/1497/2)
