codexilab / osclass-banners

Manage banners and its positions in the site
MIT License
2 stars 0 forks source link

Multiple images/banners per position #11

Open Tangol opened 3 years ago

Tangol commented 3 years ago

At the moment, the plugin allows us to add only 1 Image/Script per banner. It would be nice if we had the option to upload multiple images per every banner, as we'll have cases where a partner wants to promote 2 or more products on the same banner position.

For this I was using a simple JS that allowed me to show random banners on each page reload, based on a predefined list. Example:

<script type="text/javascript">
    var imageUrls = [
        "https://www.5banners.com/store/img/cms/00045.gif" , 
        "https://www.bannereasy.com/assets/templates/2/1071.png"
    ];
    var imageLinks = [
        "http://www.stackoverflow.com" , 
        "http://www.google.com"
    ];

    function tangoAdBoxTall() {
        var dataIndex = Math.floor(Math.random() * imageUrls.length);
        var img = '<a href=\"' + imageLinks[dataIndex] + '"><img src="';
        img += imageUrls[dataIndex];
        img += '\" title=\"Your Text!\"/></a>';
        return img;
    }
</script>
<script type="text/javascript" defer>
    document.write(tangoAdBoxTall());
</script>

Maybe this can be adapted to the Banners plugin. Thanks!