Drupal 7 开发内部培训资料, 分头诗人

请问如何让 drupal 中 '#type' => 'managed_file', 上传保存后显示的是图片而不是 图片连接

赞成!
0
否决!

请问如何让 '#type' => 'managed_file', 上传保存后显示的是图片而不是 图片连接

3 个回答

赞成!
0
否决!
// If there is a file id saved
if (!empty($v['fid'])) {
  // If there is no file path, a new file is uploaded
  // save it and try to fetch an image preview
  if (empty($v['uri'])) {
    $file = file_load($v['fid']);
    // Change status to permanent so the image remains on the filesystem. 
    $file->status = FILE_STATUS_PERMANENT;
    $file->title  = $v['title'];
    // Save.
    file_save($file);
    global $user;
    file_usage_add($file, 'node', 'node', $user->uid);
    $v = (array)$file;
  }
  $form['photos']['items'][$i]['preview']['#markup'] = theme(
    'image_style',
    array(
      'style_name' => 'form_image_preview',
      'path' => file_build_uri(file_uri_target($v['uri']))
    )
  );
}
赞成!
0
否决!

不过我不大清楚 这些代码该怎么加上去 加哪里? 我D7的

赞成!
0
否决!