Skip to content

A series of twig filters to use in Timber x WP development

License

Notifications You must be signed in to change notification settings

zenotds/twig-filters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Filters

A series of twig filters to use in Timber x WP development

slug

{{ value|slug }}

Returns a slugified version of the string. "This is a string" -> this-is-a-string

shuffle

{{ array|shuffle }}

Returns the array in shuffled/random order

svg

{{ image|svg }}

SVG inliner, replaces the instance with its svg code

iframsrc

{{ field|iframsrc }}

Extract the src portion from an iframe, eg ACF oembed field

video_id

{{ field|iframsrc }}

Extract the Youtube/Vimeo video ID from an iframe, eg ACF oembed field

sortby

{{ array|sortby(key, order) }}

Sort an array by key, asc/desc

pdf

{{ file|pdf }}

Recover the autogenerated PDF preview in its default size

fbv

{{ file/image|fbv }}

Returns the name of the Filebird folder of the file (requires plugin: FileBird Pro)

ondisk

{{ 'path'|ondisk }}

Returns true if path exists on the server (to use with static files)

readable size

{{ 'path'|size(2) }}

Converts bytesize to a readable unit. (par) sets decimal precision

Functions

uniqueid()

{{ uniqueid() }}

Generates a unique ID

$context['request']

{{ request }}

Server request powered by Laminas\Diactoros\ServerRequestFactory

About

A series of twig filters to use in Timber x WP development

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages