function textactions_evaluate_text in ImageCache Actions 5.3
Same name and namespace in other branches
- 5.2 textactions.inc \textactions_evaluate_text()
- 6 imagecache_textactions.module \textactions_evaluate_text()
Generate the dynamic text for this image. Was textactions caption - now merged as an option of text2canvas
TODO further code review for safety etc
Parameters
$image object, such as it is:
$action definition:
Return value
$text Plain string to be placed on the imagecache process.
1 call to textactions_evaluate_text()
- textactions_text2canvas_image in ./
textactions.inc - Place the source image on the current background
File
- ./
textactions.inc, line 198
Code
function textactions_evaluate_text($image, $action) {
// store our variables here
$caption = array();
// Find the image name
$caption['path'] = substr($image->source, strrpos($image->source, '/') + 1);
/*
* This just doesn't work at the moment. Needs work
*
// If the image is a cck imagefield,
// Find the image's optional title and alt text, as well as its node
if (module_exists('imagefield')) {
// a lot of work to find if the content_field_image_cache actually exists yet
$table_found = false;
$r = db_query("SHOW TABLES");
while($row = db_fetch_array($r)) {
if($row[0] == 'content_field_image_cache') {
$table_found = true;
break;
}
}
$table_found = TRUE;
if($table_found) {
// if content_field_image_cache exists,
// see if we can find info on the current image
$result = db_fetch_object(db_query("SELECT c.nid, c.field_image_cache_title, c.field_image_cache_alt FROM {content_field_image_cache} c INNER JOIN {files} f ON c.field_image_cache_fid=f.fid WHERE f.filepath = '%s'", $caption['path']));
}
if ($result) {
$caption['title']=$result->field_image_cache_title;
$caption['alt']=$result->field_image_cache_alt;
$caption['node']=node_load($result->nid);
}
}
*/
// TODO more info, like supporting data for image.module image info
// Process the php using drupal_eval (rather than eval), but with GLOBAL variables, so they can be passed successfully
$GLOBALS['caption'] = $caption;
$text = drupal_eval('<' . '?php global $caption; ' . $action['text'] . ' ?' . '>');
$text = eval($action['text']);
return $text;
}