【问题标题】:programmatically add an image to drupal node以编程方式将图像添加到 drupal 节点
【发布时间】:2013-02-12 07:57:28
【问题描述】:

我有一个想要添加的图片的 url 和一个节点对象。

如何以编程方式将图像添加到点滴 6 中的节点?

【问题讨论】:

  • 你试过什么?你知道Drupal Answers吗?
  • @Paul 这并不是说在 Drupal Answers 我们对用户提出的问题更加宽容。 :)

标签: drupal drupal-6


【解决方案1】:
function image_style_add_form($form, &$form_state) {                                       
  $form['name'] = array(                                           
    '#type' => 'textfield',                    
    '#size' => '64',                               
    '#title' => t('Style name'),                                
    '#default_value' => '',                                                
    '#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),                      
    '#element_validate' => array('image_style_name_validate'),                       
    '#required' => TRUE,                                                         
  );                                                                  

  $form['submit'] = array(                         
    '#type' => 'submit',                         
    '#value' => t('Create new style'),                      
  );                                        

  return $form;                               
}

/**                       
 * Submit handler for adding a new image style.                     
 */                                
function image_style_add_form_submit($form, &$form_state) {              
  $style = array('name' => $form_state['values']['name']);              
  $style = image_style_save($style);           
  drupal_set_message(t('Style %name was created.', array('%name' => $style['name'])));  
  $form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
}

【讨论】:

  • 很遗憾,你不明白我的意思。我的意思是这是一种编程方式,无需加载文件。
猜你喜欢
  • 2022-08-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多