本文整理汇总了PHP中RWMB_Image_Field类的典型用法代码示例。如果您正苦于以下问题:PHP RWMB_Image_Field类的具体用法?PHP RWMB_Image_Field怎么用?PHP RWMB_Image_Field使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RWMB_Image_Field类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: meta
/**
* Get post meta
*
* @param string $key Meta key. Required.
* @param int|null $post_id Post ID. null for current post. Optional
* @param array $args Array of arguments. Optional.
*
* @return mixed
*/
static function meta($key, $args = array(), $post_id = null)
{
$post_id = empty($post_id) ? get_the_ID() : $post_id;
$args = wp_parse_args($args, array('type' => 'text', 'multiple' => false));
// Always set 'multiple' true for following field types
if (in_array($args['type'], array('checkbox_list', 'file', 'file_advanced', 'image', 'image_advanced', 'plupload_image', 'thickbox_image'))) {
$args['multiple'] = true;
}
$meta = get_post_meta($post_id, $key, !$args['multiple']);
// Get uploaded files info
if (in_array($args['type'], array('file', 'file_advanced'))) {
if (is_array($meta) && !empty($meta)) {
$files = array();
foreach ($meta as $id) {
// Get only info of existing attachments
if (get_attached_file($id)) {
$files[$id] = RWMB_File_Field::file_info($id);
}
}
$meta = $files;
}
} elseif (in_array($args['type'], array('image', 'plupload_image', 'thickbox_image', 'image_advanced'))) {
if (is_array($meta) && !empty($meta)) {
$images = array();
foreach ($meta as $id) {
// Get only info of existing attachments
if (get_attached_file($id)) {
$images[$id] = RWMB_Image_Field::file_info($id, $args);
}
}
$meta = $images;
}
} elseif ('taxonomy_advanced' == $args['type']) {
if (!empty($args['taxonomy'])) {
$term_ids = array_map('intval', array_filter(explode(',', $meta . ',')));
// Allow to pass more arguments to "get_terms"
$func_args = wp_parse_args(array('include' => $term_ids, 'hide_empty' => false), $args);
unset($func_args['type'], $func_args['taxonomy'], $func_args['multiple']);
$meta = get_terms($args['taxonomy'], $func_args);
} else {
$meta = array();
}
} elseif ('taxonomy' == $args['type']) {
$meta = empty($args['taxonomy']) ? array() : get_the_terms($post_id, $args['taxonomy']);
} elseif ('map' == $args['type']) {
$field = array('id' => $key, 'multiple' => false, 'clone' => false);
$meta = RWMB_Map_Field::the_value($field, $args, $post_id);
} elseif ('oembed' == $args['type']) {
$field = array('id' => $key, 'clone' => isset($args['clone']) ? $args['clone'] : false, 'multiple' => isset($args['multiple']) ? $args['multiple'] : false);
$meta = RWMB_OEmbed_Field::the_value($field, $args, $post_id);
}
return apply_filters('rwmb_meta', $meta, $key, $args, $post_id);
}
示例2: format_single_value
/**
* Format a single value for the helper functions.
* @param array $field Field parameter
* @param array $value The value
* @return string
*/
public static function format_single_value($field, $value)
{
return RWMB_Image_Field::format_single_value($field, $value);
}
示例3: file_info
/**
* Get uploaded file information.
*
* @param int $file_id Attachment image ID (post ID). Required.
* @param array $args Array of arguments (for size).
* @return array|bool False if file not found. Array of image info on success
*/
static function file_info($file_id, $args = array())
{
return RWMB_Image_Field::file_info($file_id, $args);
}
示例4: array
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
parent::admin_enqueue_scripts();
add_thickbox();
wp_enqueue_script('media-upload');
wp_enqueue_script('rwmb-thickbox-image', RWMB_JS_URL . 'thickbox-image.js', array('jquery'), RWMB_VER, true);
}
示例5: array
/**
* Add actions
*
* @return void
*/
static function add_actions()
{
// Do same actions as file field
parent::add_actions();
// Attach images via Ajax
add_action('wp_ajax_rwmb_attach_media', array(__CLASS__, 'wp_ajax_attach_media'));
}
示例6: array
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
// Enqueue same scripts and styles as for file field
parent::admin_enqueue_scripts();
wp_enqueue_style('rwmb-plupload-image', RWMB_CSS_URL . 'plupload-image.css', array('wp-admin'), RWMB_VER);
wp_enqueue_script('rwmb-plupload-image', RWMB_JS_URL . 'plupload-image.js', array('jquery-ui-sortable', 'wp-ajax-response', 'plupload-all'), RWMB_VER, true);
wp_localize_script('rwmb-plupload-image', 'RWMB', array('url' => RWMB_URL));
wp_localize_script('rwmb-plupload-image', 'rwmb_plupload_defaults', array('runtimes' => 'html5,silverlight,flash,html4', 'file_data_name' => 'async-upload', 'multiple_queues' => true, 'max_file_size' => wp_max_upload_size() . 'b', 'url' => admin_url('admin-ajax.php'), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => _x('Allowed Image Files', 'image upload', 'rwmb'), 'extensions' => 'jpg,jpeg,gif,png')), 'multipart' => true, 'urlstream_upload' => true));
}
示例7: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
public static function html($meta, $field)
{
$i18n_title = apply_filters('rwmb_thickbox_image_upload_string', _x('Upload Images', 'image upload', 'meta-box'), $field);
// Uploaded images
$html = parent::get_uploaded_files($meta, $field);
// Show form upload
$html .= "<a href='#' class='button rwmb-thickbox-upload' data-field_id='{$field['id']}'>{$i18n_title}</a>";
return $html;
}
示例8: array
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_print_styles()
{
global $post;
// Enqueue same scripts and styles as for file field
parent::admin_print_styles();
wp_enqueue_script('plupload-all');
wp_enqueue_style('rwmb-plupload-image', RWMB_CSS_URL . 'plupload-image.css', array(), RWMB_VER);
wp_enqueue_script('rwmb-plupload-image', RWMB_JS_URL . 'plupload-image.js', array('jquery-ui-sortable', 'wp-ajax-response', 'plupload-all'), RWMB_VER, true);
//Heartcode Canvas Loader
wp_enqueue_script('heartcode-canvasloader', 'http://heartcode-canvasloader.googlecode.com/files/heartcode-canvasloader-min-0.9.1.js');
wp_localize_script('rwmb-plupload-image', 'rwmb_plupload_defaults', array('runtimes' => 'html5,silverlight,flash,html4', 'file_data_name' => 'async-upload', 'multiple_queues' => true, 'max_file_size' => wp_max_upload_size() . 'b', 'url' => admin_url('admin-ajax.php'), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => _x('Allowed Image Files', 'image upload', RWMB_TEXTDOMAIN), 'extensions' => 'jpg,gif,png')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => array('_ajax_nonce' => wp_create_nonce('plupload_image'), 'action' => 'plupload_image_upload', 'post_id' => $post->ID)));
//Links to loading and error images to allow preloading
wp_localize_script('rwmb-plupload-image', 'rwmb_plupload_status_icons', array('error' => RWMB_URL . "img/image-error.gif", 'loading' => RWMB_URL . "img/loading.gif"));
}
示例9: array
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$field['js_options'] = array('runtimes' => 'html5,silverlight,flash,html4', 'file_data_name' => 'async-upload', 'browse_button' => $field['id'] . '-browse-button', 'drop_element' => $field['id'] . '-dragdrop', 'multiple_queues' => true, 'max_file_size' => wp_max_upload_size() . 'b', 'url' => admin_url('admin-ajax.php'), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'multipart' => true, 'urlstream_upload' => true, 'filters' => array(array('title' => _x('Allowed Image Files', 'image upload', 'meta-box'), 'extensions' => 'jpg,jpeg,gif,png')), 'multipart_params' => array('field_id' => $field['id'], 'action' => 'rwmb_plupload_image_upload'));
$field = parent::normalize_field($field);
return $field;
}
示例10:
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field($field)
{
$field = parent::normalize_field($field);
$field['multiple'] = false;
return $field;
}