示例#1
0
function m4music_imagecache_generate($presetname, $filepath)
{
    if (!($preset = imagecache_preset_by_name($presetname))) {
        return;
    }
    $dst = imagecache_create_path($presetname, $filepath);
    if (!file_exists($dst)) {
        imagecache_build_derivative($preset['actions'], $filepath, $dst);
    }
    return $dst;
}
 public function index($module = '')
 {
     // using module 'imagecache'...
     echo '<pre>';
     foreach (array($this->drupalDir . '/imagecache') as $dir) {
         foreach (glob($dir . '/*.*') as $file) {
             if (in_array(substr($file, strrpos($file, '.')), array('.module', '.php', '.inc', '.class'))) {
                 require_once $file;
             }
         }
     }
     $icbd = imagecache_build_derivative(array(), $this->drupalDir . '/imagecache/sample.png', __DIR__ . '/sample-out.png');
     var_dump($icbd);
 }
  * - $view: The view object
  * - $field: The field handler object that can process the input
  * - $row: The raw SQL result that can be used
  * - $output: The processed output that will normally be used.
  *
  * When fetching output from the $row, this construct should be used:
  * $data = $row->{$field->field_alias}
  *
  * The above will guarantee that you'll always get the correct data,
  * regardless of any changes in the aliasing that might happen if
  * the view is modified.
  */
  
  // Shows the islamic posters image.
	  global $base_url;
	  $path= "sites/default/files/islamposters/". $output; 
	  $presetname = 'Islam_posters';
      $preset = imagecache_preset_by_name($presetname);
	  $src = $path;
	  $dst = imagecache_create_path($presetname, $src);
    // Ensure existing derivative or try to create it on the fly
   if (file_exists($dst) || imagecache_build_derivative($preset['actions'], $src, $dst)) {
   }
  
?>

<div style="width:600px;" align="center">
 <a href="<?php print  $base_url.'/'.$dst ?> " rel="lightbox">
<img src='<?=$base_url?>/sites/default/files/islamposters/<?php print $output;?>' height="312" width="211" align="absmiddle" border="0" />
</a>
</div>