Skip to content

Instantly share code, notes, and snippets.

<?php
// create srcset images for kirby
function img($image, $options = array()) {
// defaults
$defaults = array(
"alt" => $image->title()->or(''),
"widths" => [100, 100, 100],
"class" => "",
"lazy" => false,
);
@AugustMiller
AugustMiller / try_snippet.php
Last active April 4, 2018 12:15
Kirby snippet fallback function
<?php function try_snippet($try, $data = [], $return = false) {
$snippets = kirby::instance()->roots()->snippets();
foreach ( $try as $snippet ) {
$file = $snippets . DS . $snippet . '.php';
if ( f::exists($file) ) {
return tpl::load($file, $data, $return);
} else {
continue;
}
}