Skip to content

Instantly share code, notes, and snippets.

@clivewalker
clivewalker / image_orientation_detection.php
Last active June 19, 2019 09:32
A Perch CMS template filter to detect whether an image is portrait or landscape orientation. Written by Jay George.
/* GROUP IMAGE ORIENTATION DETECTION
=================================================== */
class PerchTemplateFilter_image_orientation_detection extends PerchTemplateFilter
{
/* Notes...
You may want to do something different if the image is landscape e.g. span 2 columns in a CSS grid rather than 1
- Assumes your template image has an ID of `image`
- e.g. `<div class="c-photo-grid__item c-photo-grid__item--<perch:content id="image" filter="image-orientation-detection" />">`
This would either output `c-photo-grid__item--landscape` or `c-photo-grid__item--portrait`
*/
@greenboyroy
greenboyroy / glossary.php
Last active October 28, 2017 06:03
Using Perch to create an alphabet of links for a collection or list/detail page.
<main role="main" class="glossary">
<div class="group">
<?php
// setup alphabet array for navigation
// make array of letters in span tags
$nav_arr = array(
'0-9' => '<span>0-9</span>'
);
for ($i = 65; $i <= 90; $i++) {
$nav_arr[chr($i)] = '<span>'.chr($i).'</span>';