From b6b58e16e6d216c6ba371db06de36fa6fcfbf167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20K=C3=BCsgen?= Date: Mon, 5 Feb 2018 17:25:11 +0100 Subject: [PATCH] refactor: use function-use instead of c::set to pass variables into function --- kirby-responsiveimage.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/kirby-responsiveimage.php b/kirby-responsiveimage.php index 8310f81..c3078da 100644 --- a/kirby-responsiveimage.php +++ b/kirby-responsiveimage.php @@ -51,7 +51,7 @@ $img->attr('width', $tag->attr('width')); $img->attr('height', $tag->attr('height')); $img->attr('class', $tag->attr('class')); - c::set('responsiveimage.html', $img); + $html = $img; if ($href = $tag->attr('link')) { $link = brick('a'); @@ -61,30 +61,28 @@ $link->attr('target', '_blank'); } - $link->append(function () { - return c::get('responsiveimage.html'); + $link->append(function () use ($html) { + return $html; }); - c::set('responsiveimage.html', $link); + $html = $link; } if (c::get('kirbytext.image.figure', true)) { $figure = brick('figure'); - $figure->append(function () { - return c::get('responsiveimage.html'); + $figure->append(function () use ($html) { + return $html; }); if ($caption = $tag->attr('caption')) { - c::set('repsonsiveimage.figure.caption', $caption); - - $figure->append(function() { - return brick('figcaption', c::get('repsonsiveimage.figure.caption', false)); + $figure->append(function() use ($caption) { + return brick('figcaption', $caption); }); } - c::set('responsiveimage.html', $figure); + $html = $figure; } - return c::get('responsiveimage.html'); + return $html; } ]);