-2

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

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

4

1 回答 1

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'];
}
于 2013-02-12T11:09:29.757 回答