4
I need to implement the following: category buttons + category gallery
I have several categories on my site and an image gallery for each one. On the front, I will create buttons with the categories and just below a slider.
I need to click on a category button, stay on the slider, only the images referring to that category.
Ps: ignore the 'all' button because it will not have
Follow the codes I already have:
$("#Glide").glide({
    type: "carousel",
    autoplay: 0
});
$(".filter-button").click(function () {
    var value = $(this).attr('data-filter');
    if (value == "all") {
        $('.filter').show();
    }
    else {
        $(".filter").not('.' + value).hide();
        $('.filter').filter('.' + value).show();
    }
});.glide {
    margin: 0 auto;
    width: 300px;
}<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">        
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/glide.core.css">        
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/glide.theme.css">        
    <title>Gallery Filter By Category</title>
</head>
<body>
    <div align="center">
        <button class="filter-button" data-filter="all">All</button>
        <button class="filter-button" data-filter="c1">Category 1</button>
        <button class="filter-button" data-filter="c2">Category 2</button>
        <button class="filter-button" data-filter="c3">Category 3</button>
        <button class="filter-button" data-filter="c4">Category 4</button>
    </div>
    <br>
    <br>
    <br>
    <br>
    <br>
    <div id="Glide" class="glide">
        <div class="glide__arrows">
            <button class="glide__arrow prev" data-glide-dir="<">prev</button>
            <button class="glide__arrow next" data-glide-dir=">">next</button>
        </div>
        <div class="glide__wrapper">
            <ul class="glide__track">
                <li class="glide__slide filter c1">
                    <img src="https://fakeimg.pl/300x300/a4c400/?text=category1&font=lobster&font_size=55">
                </li>
                <li class="glide__slide filter c3">
                    <img src="https://fakeimg.pl/300x300/0050ef/?text=category3&font=lobster&font_size=55">
                </li>
                <li class="glide__slide filter c1">
                    <img src="https://fakeimg.pl/300x300/a4c400/?text=category1&font=lobster&font_size=55">
                </li>
                <li class="glide__slide filter c2">
                    <img src="https://fakeimg.pl/300x300/00aba9/?text=category2&font=lobster&font_size=55">
                </li>
                <li class="glide__slide filter c3">
                    <img src="https://fakeimg.pl/300x300/0050ef/?text=category3&font=lobster&font_size=55">
                </li>
                <li class="glide__slide filter c4">
                    <img src="https://fakeimg.pl/300x300/d80073/?text=category4&font=lobster&font_size=55">
                </li>
                <li class="glide__slide filter c2">
                    <img src="https://fakeimg.pl/300x300/00aba9/?text=category2&font=lobster&font_size=55">
                </li>
            </ul>
        </div>
    </div>
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/glide.js"></script>    
    
</body>
</html>
Will you upload all the images at once and then filter, or will you change the content of the gallery by clicking the buttons? Have a look at that link see if it’s more or less the idea.
– Grupo CDS Informática
A: That’s about it, but in the case of this example, it exchanges loose images, I need mine to work inside the slider the problem is to set javascript for the slider to work
– J. Marco
Join the idea this one with the other’s filter logic I believe is ideal.
– Grupo CDS Informática