valendesigns/option-tree — pull request #308 by krisarsov (2014-04-19 15:14:07+00:00)
Title: Meta Box: "Upload" type to store attachment ID rather than absolute URL

Currently the "Upload" type saves the absolute URL into the post meta.

The following changes aim to enable the users to store the attachment ID of the media uploaded rather than just the absolute URL.

With the stored attachment ID they can later fetch different thumbnail sizes and attachment information.

**By default it will still store the absolute URL.**

To switch to storing the attachment ID when defining the meta box fields add a [params][save_attachment_id] key into the definition like this:
```
$my_meta_box = array(
'id' => 'my_meta_box',
'title' => __( 'Images', 'text_domain' ),
'desc' => '',
'pages' => array('page'),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'id' => 'homepage_promo',
'label' => __( 'Image items', 'text_domain' ),
'desc' => '',
'std' => '',
'type' => 'list_item',
'class' => '',
'choices' => array(),
'settings' => array(
array(
'id' => 'image',
'label' => __( 'Image', 'taxistars' ),
'desc' => '',
'std' => '',
'type' => 'upload',
'params' => array(
'save_attachment_id' => true
),
)
)
)
)
);
```

Setting **[params][save_attachment_id] = false** or not setting it at all will fallback to the default behavior **(store the absolute URL)**.