Thumbnails for Article Link Instead of the Bullet Lists

3 Comments

  • Tal Admon

    Hi Jennifer,

    Please see the example here:

    https://moderatortal.zendesk.com/hc/en-us/sections/201783699-Section-one

    The links to the articles are replaced with the first image in the article itself (make sure all your articles contain images!).

    The following script will do the magic:

    Place it in a "script" tag in the beginning of the Section Page in the theme customization.

    Replace the section ID in the IF clause to the section you want to apply this on.

    $(document).ready(function(){
    if (window.location.pathname.indexOf('/sections/201783699')!=-1) {
    $('.article-list li').each(function(i){
    var item = new Array();
    var obj = new Array();
    var artLink = new Array();
    var artImage = new Array();
    var artName = new Array();
    item[i]=$(this);
    artLink[i] = $(this).find('a').attr('href');
    artName[i] = $(this).find('a').html();
    obj[i] = $.ajax(artLink[i]).done(function(){
    artImage[i] = $('.article-body img',obj[i].responseText).attr('src');
    item[i].html('<a href="'+artLink[i]+'"><img src="'+artImage[i]+'" alt="'+artName[i]+'" title="'+artName[i]+'"></a>');
    });
    });
    };
    });
    1
  • Jennifer Morris

    This is exactly what I am looking for thank you. I will give it a try.

    0

Please sign in to leave a comment.

Powered by Zendesk