Page 1 of 1

Showing amount only if more than one

Posted: 17 Aug 2017, 03:49
by Haider of Sweden
Hi!

I need to show image amount only if there are more than one.
How can I do that?

Re: Showing amount only if more than one

Posted: 17 Aug 2017, 04:46
by mjau-mjau
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.

Re: Showing amount only if more than one

Posted: 17 Aug 2017, 10:20
by Haider of Sweden
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();

Re: Showing amount only if more than one

Posted: 17 Aug 2017, 10:23
by mjau-mjau
Good job!  :thumbsup: :star: :star: