Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Last active August 4, 2017 10:45
Show Gist options
  • Save bastianallgeier/ccd90c483153f915a380 to your computer and use it in GitHub Desktop.
Save bastianallgeier/ccd90c483153f915a380 to your computer and use it in GitHub Desktop.
<!-- create the complete html img tag for a given image -->
<?= $page->image()->html() ?>
<!-- modify the attributes of the img tag -->
<?= $page->image()->html(['class' => 'myImage']) ?>
<!-- resize an image first and then get the img tag for it -->
<?= $page->image()->resize(300,200)->html() ?>
<!-- crop an image first and then get the img tag for it -->
<?= $page->image()->crop(300)->html() ?>
<!-- build a link tag for any field. The url of the page will be used for the href -->
<?= $page->title()->link() ?>
<!-- customize the url -->
<?= $page->title()->link('some/page') ?>
<!-- customize the attributes -->
<?= $page->title()->link(['class' => 'myLink']) ?>
<!-- customize the url and attributes -->
<?= $page->title()->link('some/page', ['class' => 'myLink']) ?>
<!-- convert a custom field value to an absolute url -->
<?= $page->related()->url() ?>
<!-- convert a custom field value to an integer -->
<?= $page->myInt()->int() ?>
<!-- convert a custom field value to a float -->
<?= $page->myFloat()->float() ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment