Skip to content

Instantly share code, notes, and snippets.

echo $item->fieldname;
// Output file name 1
echo $item->fieldname->file_name[0];
// Output file name 2
echo $item->fieldname->file_name[1]
// ...
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.'">';
}
// Bootstrapping PHPThumb library
require_once(GSPLUGINPATH.'imanager/phpthumb/ThumbLib.inc.php');
echo getResized($item->fields->images, 1, $x);
echo getResized($item->fields->images, 1, 200);
echo getResized($item->fields->images, 1, 0, 200);
foreach($item->fields->images->file_name as $key => $name) {
echo getResized($item->fields->images, $key, 0, 200).'<br>';
}
for($i=0; $i<count($item->fields->images->file_name); $i++) {
echo getResized($item->fields->images, $i, 0, 200).'<br>';
}
<?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
*