Skip to content

Instantly share code, notes, and snippets.

@davidmars
Created August 26, 2014 04:22
Show Gist options
  • Save davidmars/d29e32c389b74d39ee05 to your computer and use it in GitHub Desktop.
Save davidmars/d29e32c389b74d39ee05 to your computer and use it in GitHub Desktop.
Some wysiwyg image field sample
<?php
/*
Some image sample
*/
/** @var VV_post|VV_block $vv **/
?>
<img class="ce-que-vous-voulez"
<?=$vv->wysiwyg()
->attrFieldImg
(
"thumbnail", //we will record the image url in the $vv->thumbnail field
Robert::getFormat()->sizedByWidth(400)->jpg() //the displayed image will be a 400px width jpg. The height will be deduced
)
?>
/>
<img class="ce-que-vous-voulez"
<?=$vv->wysiwyg()
->attrFieldImg
(
"extraVars[myCustomImageField]", //we will record the image url in the $vv->extraVars["myCustomImageField"] field
Robert::getFormat()->sizedByWidth(400)->jpg(10) //the displayed image will be a 400px width jpg with a 10% compression. The height will be deduced
)
?>
/>
<img class="ce-que-vous-voulez"
<?=$vv->wysiwyg()
->attrFieldImg
(
"myImageField", //in a block it will be ok, in a VV_post will produce an error because the $vv->myImageField field is not defined in the VV_post model
Robert::getFormat()->sizedShowAll(400,400)->png() //the displayed image will be a 400px x 400px image and all the image will be visible, so this png will probabily contains som transparency
)
?>
/>
<img class="ce-que-vous-voulez"
<?=$vv->wysiwyg()
->attrFieldImg
(
"thumbnail",
Robert::getFormat()->sizedShowAll(400,400)->background("ff0000")->jpg() //the displayed image will be a 400px x 400px jpg and all the image will be visible, the background will be red
)
?>
/>
<img class="ce-que-vous-voulez"
<?=$vv->wysiwyg()
->attrFieldImg
(
"thumbnail",
Robert::getFormat()->sizedNoBorder(400,300)->jpg(), //the displayed image will be a 400px x 300px jpg and the image will be cropped to fit the 400 by 400 rectangle.
)
->disablePhotoFilter() //The admin user will not be able to choose photo filters
?>
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment