Skip to content

Instantly share code, notes, and snippets.

html,body {
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
font:inherit;
vertical-align:baseline;
}
$item = imanager()->getItemMapper()->init(8, 50);
// Accessing a field value
echo $item->fields->fieldname->value;
$item = imanager()->getItemMapper()->init(8, 50);
// Accessing an item attribute
echo $item->name;
foreach($item->fields->fieldname->fullurl as $key => $url) {
// Output an image with title and url
echo '<img alt="'.$item->fields->fieldname->title[$key].'" src="'.$url.'">';
}
<?php
/**
* Class ItemSimplificator, just a simple decorator class
*/
class ItemSimplificator
{
protected $_item;
public function __construct(Item $item) {
$this->_item = $item;
// get an item with the id 50 of the category 8
$item = imanager()->getItemMapper()->init(8, 50);
// simplify item
$item = new ItemSimplificator($item);
echo $item->fieldname;
// Output file name 1
echo $item->fieldname->file_name[0];
// Output file name 2
echo $item->fieldname->file_name[1]
// ...
// Bootstrapping PHPThumb library
require_once(GSPLUGINPATH.'imanager/phpthumb/ThumbLib.inc.php');
<?php
/**
* Returns resized image
* With the first call creates thumbnail and cached it
*
* @param object $image - A Field object of an item
* @param integer $id - An index of the field value
* @param integer $width - Thumb width
* @param integer $height - Thumb height
*