You are here

function ml_image_get_image in Media Library 6

Load single image object by fid

2 calls to ml_image_get_image()
ml_image_basic_existing_options_form_submit in ml_image/ml_image_basic/ml_image_basic.module
Submit of image selection stage
ml_image_nodeapi in ml_image/ml_image.module
Implementation of hook_nodeapi()

File

ml_image/ml_image.module, line 637
Media Library Image module.

Code

function ml_image_get_image($fid) {
  static $images;
  if (!is_array($images)) {
    $images = array();
  }
  if (!isset($images[$fid])) {

    // Base query
    $query = '
      SELECT
        metadata.*,
        files.filepath,
        files.uid,
        files.timestamp,
        GROUP_CONCAT(tags.tid) as tags
      FROM {ml_image_metadata} metadata
      INNER JOIN {files} files ON metadata.fid = files.fid
      LEFT JOIN {ml_image_term} tags ON metadata.fid = tags.fid
      WHERE metadata.fid = %d
      GROUP BY metadata.fid';
    $image = db_fetch_object(db_query($query, $fid));
    if ($image) {
      $images[$fid] = $image;
    }
  }
  return $images[$fid];
}