Have a question about CiviCRM? Get it answered quickly at the new CiviCRM Stack Exchange Q+A siteThis forum was archived on 25 November 2017. Learn more.How to get involved.What to do if you think you've found a bug.
// Clear Theme cache. Remove before going live.drupal_rebuild_theme_registry(); // clear theme cache on each page load
<?php// $Id: views-view-fields.tpl.php,v 1.6 2008/09/24 22:48:21 merlinofchaos Exp $/** * @file views-view-fields.tpl.php * Default simple view template to all the fields as a row. * * - $view: The view in use. * - $fields: an array of $field objects. Each one contains: * - $field->content: The output of the field. * - $field->raw: The raw data for the field, if it exists. This is NOT output safe. * - $field->class: The safe class id to use. * - $field->handler: The Views field handler object controlling this field. Do not use * var_export to dump this object, as it can't handle the recursion. * - $field->inline: Whether or not the field should be inline. * - $field->inline_html: either div or span based on the above flag. * - $field->separator: an optional separator that may appear before a field. * - $row: The raw result object from the query, with all data it fetched. * * @ingroup views_templates */?><?php $image_uri = url(get_civicrm_image($fields['image_1']->content)); echo $image_uri; ?><img src="<?php echo $image_uri; ?>" />
//This reads the CiviEvents image field ID and replaces it with its associated image file. function get_civicrm_image($id, $dimensions=array(200,200)) { civicrm_initialize(); require_once('api/File.php'); // get the file details$file = crm_get_file(array('id'=>$id)); die(print_r($file, TRUE)); $filename = $file['uri']; $root = $_SERVER['DOCUMENT_ROOT']; $file_ext = strrchr($filename, '.'); $file_base = substr($filename, 0, 0 - strlen($file_ext)); $old_path = $root . '/' . file_directory_path() . '/civicrm/custom/' . $filename; $new_file = file_directory_path() . '/civicrm/custom/' . $file_base . '_' . $dimensions[0] . 'x' . $dimensions[1] . $file_ext; if(!file_exists($root . '/' . $new_file)) { image_scale_and_crop($old_path, $root . '/' . $new_file, $dimensions[0], $dimensions[1]); } return $new_file;}
$scale = max($width / $info['width'], $height / $info['height']);
u;ll might want to interact with each other on the CiviCRM IRC Channel: http://webchat.freenode.net/?channels=#civicrm
$old_path = $root . '/' . file_directory_path() . '/civicrm/custom/' . $filename;
if(file_exists($old_path)) { die('found file: ' . $old_path'); }else { die('couldn't find file: ' . $old_path); }
else { die('could not find file: ' . $old_path); }