Search code examples
tumblr

Can I break a block {PhotoSet} in tumblr?


Suppose that I have defined 5 custom posts, and in each of them I defined photoset to post multiple photos. But in each of one I only want to execute 1 time and get the 1 photo. So how can I break a photoset block?

{block:Photoset}
     <article>
        <span class="break" style="padding-bottom: 19px;"></span>

        <!-- Go through each Photo in the Photoset -->
        {block:Photos}
            <img src="{PhotoURL-HighRes}" class="highres">
        {/block:Photos}

        {block:Caption}
            <p>{Caption}</p>
        {/block:Caption}
        <p></p>
        <time>{TimeAgo}</time>
    </article>
{/block:Photoset}

Something like this:

{block:Photoset}
     <article>
        <span class="break" style="padding-bottom: 19px;"></span>

        <!-- Go through each Photo in the Photoset -->
        {block:Photos}
            <img src="{PhotoURL-HighRes}" class="highres">
        {/block:Photos}

        {block:Caption}
            <p>{Caption}</p>
        {/block:Caption}
        <p></p>
        <time>{TimeAgo}</time>
    </article>

**BREAK HERE??**

{/block:Photoset}

Solution

  • There doesn't seem to be a way to limit them, but you can comment them out:

    {block:Photoset}
         <article>
            <span class="break" style="padding-bottom: 19px;"></span>
    
            <!-- Go through each Photo in the Photoset -->
            {block:Photos}
                <img src="{PhotoURL-HighRes}" class="highres">
                I assume you want the break here
                <!--
            {/block:Photos}
            -->
    
            {block:Caption}
                <p>{Caption}</p>
            {/block:Caption}
            <p></p>
            <time>{TimeAgo}</time>
        </article>
    {/block:Photoset}
    

    See that <!-- before {/block:Photos}? That opens an HTML comment right after the first image, so the rest of the images in the loop will be in a comment, invisible. After the loop we close the comment with -->. Done, all the images in the photoset after the first one will be hidden.