Appearance
Image Lightbox Using Column Transform Value
If your table has a column of image URLs, for example from a connected Google Sheet, the cells show the links as plain text. With Transform value (Pro) you can show each URL as an image and open it in a lightbox when clicked.
For tables that keep their own rows, the Image/File/Lightbox column type does this without any code.
Example table
This example uses a Google Sheet about car models with two columns: Name and Image. The Image column holds image URLs. When you connect the Google Sheet, the columns come in automatically, but the image links show as text.
Show the URLs as images
- Go to Ninja Tables › Tables › your table › Table Rows.
- Click the gear icon on the Image column, choose Column settings, and open the Transform tab.
- In the Transform value box, enter an image tag with the column's reference shortcode as the source. For a column with the key
image:
html
<img src="{{row.image}}">- Click Save column. Every image URL in the column now shows as an image.
Each column's reference shortcode is in the Reference values list under the Transform value box. Click a row in the list to insert it.
Open the images in a lightbox
- In the same Transform value box, wrap the image in a link with the
nt_lightboxclass:
html
<a href="{{row.image}}" class="nt_lightbox"><img src="{{row.image}}"></a>- Click Save column.
- Open the Custom CSS/JS tab. Under Table Targeting, type
nt_has_lightboxin Custom CSS class, then click Save. This class tells the table to load the lightbox.
Preview the table. The images now open in a lightbox when clicked.
Use FooTable for this method
The nt_has_lightbox class loads the lightbox on FooTable tables. On DataTables tables the class doesn't load the lightbox by itself, so the images show but may not open in a lightbox. See FooTable or DataTables.