Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
Haider of Sweden
Experienced
Topic Author
Posts: 54
Joined: 09 Jan 2013, 05:02

Showing amount only if more than one

17 Aug 2017, 03:49

Hi!

I need to show image amount only if there are more than one.
How can I do that?
Kind regards,
Haider
www.haider.se
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14452
Joined: 30 Sep 2006, 03:37

Re: Showing amount only if more than one

17 Aug 2017, 04:46

Haider of Sweden wrote:I need to show image amount only if there are more than one.
This cannot be done. If you specifically enable "image amount", and as long as there is at least one image, it will display the image amount. There is no setting "display image amount only if there are two or more images". If you were gonna do this, it would have to be hacked by javascript, something I can't just do on short notice.
 
User avatar
Haider of Sweden
Experienced
Topic Author
Posts: 54
Joined: 09 Jan 2013, 05:02

Re: Showing amount only if more than one

17 Aug 2017, 10:20

Thank you for pointing me to the right direction. Javascript solved it.
If anyone else might need to know, this is how it was solved:

Code
function hideOneImage(){
    var elements = document.getElementsByClassName("amount")
    for (var i = 0; i < elements.length; i++){
        if(elements[i].innerHTML == "1 image"){
            elements[i].style.display = "none";
        }
    }
}

hideOneImage();
Kind regards,
Haider
www.haider.se
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14452
Joined: 30 Sep 2006, 03:37

Re: Showing amount only if more than one

17 Aug 2017, 10:23

Good job!  :thumbsup: :star: :star: