demtario / hes-gallery

Light, dependency free, responsive gallery script
https://demtario.github.io/hes-gallery/demo/
MIT License
30 stars 2 forks source link

feature_request(option): images in the different places in one gallery #21

Open Kristinita opened 2 years ago

Kristinita commented 2 years ago

1. Summary

It would be nice, if would be possible to include to one gallery images that are in different parts of the HTML page.

That is, add some option so that the behavior of hes-gallery in the second example is the same as in the first example.

2. Examples

2.1. One gallery MCVE

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Kira hes-gallery all in one gallery</title>
        <script src="https://cdn.jsdelivr.net/npm/hes-gallery/dist/hes-gallery.min.js" defer></script>
    </head>
    <body>
        <div class="hes-gallery">
            <img alt="First image description" src="https://64.media.tumblr.com/b46755ce8132f94072dc11ff1bc521f2/tumblr_o9c27npEFz1st5lhmo1_1280.jpg">
            <img alt="Second image description" src="https://64.media.tumblr.com/e448b56e7d05e08fc7d50fba6279162a/tumblr_o9c384UrKV1st5lhmo1_1280.jpg">
            <img alt="Third image description" src="https://64.media.tumblr.com/6a3c1841255255d81f00adc0559ae3e1/tumblr_o9c2klYKxX1st5lhmo1_1280.jpg">
        </div>
    </body>
</html>

All 3 images included in one gallery.

Kira hes-gallery one gallery

2.2. 3 galleries MCVE

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
-       <title>Kira hes-gallery all in one gallery</title>
+       <title>Kira hes-gallery 3 different galleries</title>
        <script src="https://cdn.jsdelivr.net/npm/hes-gallery/dist/hes-gallery.min.js" defer></script>
    </head>
    <body>
        <div class="hes-gallery">
            <img alt="First image description" src="https://64.media.tumblr.com/b46755ce8132f94072dc11ff1bc521f2/tumblr_o9c27npEFz1st5lhmo1_1280.jpg">
+       </div>
+       <p>Between the gallery images may be something</p>
+       <div class="hes-gallery">
            <img alt="Second image description" src="https://64.media.tumblr.com/e448b56e7d05e08fc7d50fba6279162a/tumblr_o9c384UrKV1st5lhmo1_1280.jpg">
+       </div>
+       <p>It may or may not be related to gallery images</p>
+       <div class="hes-gallery">
            <img alt="Third image description" src="https://64.media.tumblr.com/6a3c1841255255d81f00adc0559ae3e1/tumblr_o9c2klYKxX1st5lhmo1_1280.jpg">
        </div>
    </body>
</html>

hes-gallery creates 3 different galleries.

Kira hes-gallery 3 different galleries

3. Argumentation

As far as I understand, that to be included in one gallery, images must be placed inside one tag <div class="hes-gallery">.

But content creators, for various reasons, may want to put in one gallery not solely images that are nearby. For example, I want all screenshots on this page it would be possible to view in one gallery. But, unfortunately, I don’t understand how I can do it using hes-gallery 1.5.1. Related images, located in different places on the page, may be comfortable to watch in one gallery.

Thanks.

demtario commented 2 years ago

Hi, <img> tags does not need to be a direct childs of the .hes-gallery class wrapper. You can wrap whole content with this class, and all images should be loaded into one gallery

Example below:

<div class="hes-gallery">
  <h1>Hello world</h1>
  <p>Lorem ipsum</p>
  <img src="test.png" />
  <div class="grid">
    <img src="test2.png" />
    <img src="test2.png" />
    <img src="test2.png" />
  </div>
</div>

Or based on your example:

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Kira hes-gallery all in one gallery</title>
        <script src="https://cdn.jsdelivr.net/npm/hes-gallery/dist/hes-gallery.min.js" defer></script>
    </head>
-   <body>
+   <body class="hes-gallery">
-       <div class="hes-gallery">
+       <div>
            <img alt="First image description" src="https://64.media.tumblr.com/b46755ce8132f94072dc11ff1bc521f2/tumblr_o9c27npEFz1st5lhmo1_1280.jpg">
        </div>
        <p>Between the gallery images may be something</p>
-       <div class="hes-gallery">
+       <div>
            <img alt="Second image description" src="https://64.media.tumblr.com/e448b56e7d05e08fc7d50fba6279162a/tumblr_o9c384UrKV1st5lhmo1_1280.jpg">
        </div>
        <p>It may or may not be related to gallery images</p>
-       <div class="hes-gallery">
+       <div>
            <img alt="Third image description" src="https://64.media.tumblr.com/6a3c1841255255d81f00adc0559ae3e1/tumblr_o9c2klYKxX1st5lhmo1_1280.jpg">
        </div>
    </body>
</html>
Kristinita commented 2 years ago

Status: It doesn’t completely solve the problem :x:

1. Early closing

@demtario, I’m not sure that closing an issue as “completed” 3 days after the own reply without waiting for the reply of the creator of the issue is the best practice.

2. Problem — unexpected images

Even if the user wants to include all the images of an article in a single gallery (as in my example), interface icons and other unwanted images can also end up in the gallery.

Clipboard image in hes-gallery

Also, users may want to include in the single gallery some images (on the different places of the page), but not others, for other reasons.

It would be nice if it would be possible without hard-coding.

3. Possible solutions

  1. For example, class hes-gallery-all. hes-gallery will include all images on the page inside <div class="hes-gallery-all"></div> into a single gallery.
  2. Or perhaps an option ignoredClasses. Values — a list of img classes for which hes-gallery will not be applied. For example, if ignoredClasses: ["KiraInterfaceIcon"], hes-gallery will not add <img class="KiraInterfaceIcon"> to galleries.

Thanks.

demtario commented 2 years ago

Forgive me for closing the issue, but ignoring some images sounds to me like a completely different issue than multiple images in different places in one gallery mentioned in title and your primary description.

Nevertheless, the solution with adding a configurable class/attribute that will be ignored by hes-gallery sounds like a sensible idea. I will try to implement something like this in the near future