-
-
Save milojennings/7604926 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class kirbytextExtended extends kirbytext { | |
function __construct($text, $markdown=true) { | |
parent::__construct($text, $markdown); | |
$this->addTags('figure'); | |
$this->addAttributes('caption', 'credits'); | |
} | |
function figure($params) { | |
global $site; | |
$page = ($this->obj) ? $this->obj : $site->pages()->active(); | |
$image = $page->images()->find($params['figure']); | |
$defaults = array( | |
'caption' => '', | |
'credits' => '' | |
); | |
// merge the given parameters with the default values | |
$options = array_merge($defaults, $params); | |
$imageurl = $image->url() ; | |
$imagecaption = $options['caption'] ; | |
$imagecredits = $options['credits'] ; | |
return '<figure><img src="' . $imageurl . '" alt="' . $imagecaption . '"><figcaption><span class="caption">' . $imagecaption . '</span><span class="image-credits">' . $imagecredits . '</span></figcaption></figure>'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment