function node_gallery_get_image_filepath in Node Gallery 6.3
Returns the filepath(s) to an imagefield item - saving a full node_load().
Parameters
$nids: The nid(s) of the node.
$fieldname: The name of the imagefield.
Return value
If a single nid is passed in, a single filepath string is returned. If an array of nids are passed in, it returns an array of filepaths.
1 call to node_gallery_get_image_filepath()
- theme_node_gallery_manage_images_form in theme/
theme.inc - @file Node gallery theme functions
File
- ./
node_gallery.inc, line 886 - Shared functions for node_gallery
Code
function node_gallery_get_image_filepath($nids, $fieldname) {
static $fields = array();
if (!isset($fields[$fieldname])) {
$fields[$fieldname]['field'] = content_fields($fieldname);
$fields[$fieldname]['db_info'] = content_database_info($fields[$fieldname]['field']);
}
$table = $fields[$fieldname]['db_info']['table'];
$sql = 'SELECT nid, filepath FROM {' . $table . '} JOIN {files} on {' . $table . '}.' . $fieldname . '_fid = {files}.fid ';
if (!is_array($nids)) {
$sql .= 'WHERE nid = %d';
$file = db_fetch_array(db_query($sql, $nids));
$filepath = $file['filepath'];
}
else {
$sql .= 'WHERE nid IN (' . db_placeholders($nids) . ')';
$result = db_query($sql, $nids);
while ($file = db_fetch_array($result)) {
$filepaths[$file['nid']] = $file['filepath'];
}
foreach ($nids as $nid) {
$filepath[] = $filepaths[$nid];
}
}
return $filepath;
}