Pull the first image from a Tumblr photoset?

前端 未结 3 2093
执笔经年
执笔经年 2021-02-06 18:26

I\'m designing a theme for a wedding photographer who wants to use Tumblr\'s Photoset functionality to create a portfolio site.

How do I pull the first image from a phot

3条回答
  •  别那么骄傲
    2021-02-06 19:08

    the above example is flawed as the user has to download all the images even though only the first is shown so instead I've used jquery to inject only the first image.

    HTML (simplified):

    {block:Photoset}
        
    {block:Photos}
    {/block:Photos}
    {block:Photoset}

    javascript (simplified):

    $(document).ready(function() {
        $(".photoset .photoPlaceholder").first().each(function (i) {
            var src = $(this).attr("imgsrc");
            $(this).html('');
        });
    });
    

    This ensures only the first image is loaded... you can always have the other css example above in a noscript tag incase they have javascript turned off.

    Hope that helps

提交回复
热议问题