Question

I'm using Stylehatch's 'Photoset-grid.js' and 'view.js'

It seems to work, aside for this fact: When I click on the right-most image in a multi-image row, it opens the left image.

To see what I mean: http://test-theme-one.tumblr.com/

My rendered HTML looks like this (I went to safari and clicked "inspect element", and copied the html for a photoset post on my test blog) I don't understand how it is setup, I though I had it so an anchor would wrap each image in the photoset?

<div class="photoset-grid" data-layout="3" style="width: 100%;" data-width="500">
<a href="http://31.media.tumblr.com/4738e9e1fe4f307b7c7313bcf96766a6/tumblr_msk013TnG61syxzvzo2_500.png" class="view" rel="60178651810" title="help">
    <div class="photoset-row cols-3" style="clear: left;display: block;overflow: hidden;height: 80px;">
        <div class="photoset-cell" style="float: left;display: block;line-height: 0;box-sizing: border-box;width: 33.3%;padding-right: 2.5px;">
            <img src="http://31.media.tumblr.com/4738e9e1fe4f307b7c7313bcf96766a6/tumblr_msk013TnG61syxzvzo2_500.png" alt="" style="width: 100%;height: auto;margin-top: 0px;">
        </div>

        <div class="photoset-cell" style="float: left;display: block;line-height: 0;box-sizing: border-box;width: 33.3%;padding-right: 2.5px;padding-left: 2.5px;">
            <img src="http://31.media.tumblr.com/b421d5cbc68a1f63091492cc95cf879e/tumblr_msk013TnG61syxzvzo3_500.jpg" alt="" style="width: 100%;height: auto;margin-top: -84.5px;">
        </div>

        <div class="photoset-cell" style="float: left;display: block;line-height: 0;box-sizing: border-box;width: 33.3%;padding-left: 2.5px;">
            <img src="http://25.media.tumblr.com/2a4e3311cad4a928b49460b9ed6fda1e/tumblr_msk013TnG61syxzvzo1_500.png" alt="" style="width: 100%;height: auto;margin-top: 0px;">
        </div>

    </div>
</a>

<a href="http://31.media.tumblr.com/b421d5cbc68a1f63091492cc95cf879e/tumblr_msk013TnG61syxzvzo3_500.jpg" class="view" rel="60178651810" title="me"></a>

<a href="http://25.media.tumblr.com/2a4e3311cad4a928b49460b9ed6fda1e/tumblr_msk013TnG61syxzvzo1_500.png" class="view" rel="60178651810" title="please ;)"></a>
</div>
Was it helpful?

Solution

The problem is that Photoset Grid wasn't really designed for template work. It takes this template:

 {block:Photos}
      <a href="{PhotoURL-500}" class="view" rel="{PostID}">
            <img src="{PhotoURL-500}" alt="{PhotoAlt}"/>
      </a>
 {/block:Photos}

And pulls out all <img> tags and duplicates them--one per image in the row. It results in this HTML:

<a class="view" ... >
    <div class="photoset-row cols-3" ...>
        <div class="photoset-cell" ...>
            <img ...>
        </div>
        <div class="photoset-cell" ...>
            <img ...>
        </div>
        <div class="photoset-cell" ...>
            <img ...>   
        </div>
    </div>
</a>
<a class="view" ... ></a>
<a class="view" ... ></a>

Now, view.js is using anchors/links to pop open the lightbox. They are basically capturing the click event for the entire grouping. When, in your template, you attempt to wrap the <img> in an <a>, it is pulling out the <img> tag out of the <a> in the template and appending them to the first <a>.

If you're up on jQuery plugin development, the Photoset-grid code, is pretty clearly bugged around line 113 (_setupColumns).

Long story short, you're not going to be able to use view.js lightbox with the Photoset-grid. Unless some kind soul comes along and fixes the plugin.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top