本文整理汇总了PHP中wp_mime_type_icon函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_mime_type_icon函数的具体用法?PHP wp_mime_type_icon怎么用?PHP wp_mime_type_icon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_mime_type_icon函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_file
function render_file($id = null)
{
if (!$id) {
echo "";
return;
}
// vars
$file_src = wp_get_attachment_url($id);
preg_match("~[^/]*\$~", $file_src, $file_name);
$class = "active";
?>
<ul class="hl">
<li data-mime="<?php
echo get_post_mime_type($id);
?>
">
<img class="acf-file-icon" src="<?php
echo wp_mime_type_icon($id);
?>
" alt=""/>
</li>
<li>
<span class="acf-file-name"><?php
echo $file_name[0];
?>
</span><br />
<a href="javascript:;" class="acf-file-delete"><?php
_e('Remove File', 'acf');
?>
</a>
</li>
</ul>
<?php
}
示例2: get_preview_from_url
public static function get_preview_from_url($url)
{
$preview = '';
$images = array('jpg', 'jpeg', 'bmp', 'gif', 'png');
if (filter_var($url, FILTER_VALIDATE_URL) !== FALSE) {
// check for extension, if it has extension then use it
$info = pathinfo($url);
if (isset($info['extension'])) {
if (in_array($info['extension'], $images)) {
$preview = $url;
} else {
$type = wp_ext2type($info['extension']);
if (is_null($type)) {
$type = 'default';
}
$preview = includes_url() . 'images/crystal/' . $type . '.png';
}
} else {
// if no extension, try to discover from mime
$mime = wp_remote_head($url);
if (!is_wp_error($mime)) {
$mime = $mime['headers']['content-type'];
if (strpos($mime, 'image') === 0) {
$preview = $url;
} else {
$preview = wp_mime_type_icon($mime);
}
} else {
$preview = includes_url() . 'images/crystal/' . 'default' . '.png';
}
}
}
return $preview;
}
示例3: attach_html
public static function attach_html($attach_id, $type = NULL)
{
if (!$type) {
$type = isset($_GET['type']) ? $_GET['type'] : 'image';
}
$attachment = get_post($attach_id);
if (!$attachment) {
return;
}
if (wp_attachment_is_image($attach_id)) {
$image = wp_get_attachment_image_src($attach_id, 'thumbnail');
$image = $image[0];
} else {
$image = wp_mime_type_icon($attach_id);
}
$html = '<li class="wpuf-image-wrap thumbnail">';
$html .= sprintf('<div class="attachment-name"><img src="%s" alt="%s" /></div>', $image, esc_attr($attachment->post_title));
if (wpuf_get_option('image_caption', 'wpuf_general', 'off') == 'on') {
$html .= '<div class="wpuf-file-input-wrap">';
$html .= sprintf('<input type="text" name="wpuf_files_data[%d][title]" value="%s" placeholder="%s">', $attach_id, esc_attr($attachment->post_title), __('Title', 'wpuf'));
$html .= sprintf('<textarea name="wpuf_files_data[%d][caption]" placeholder="%s">%s</textarea>', $attach_id, __('Caption', 'wpuf'), esc_textarea($attachment->post_excerpt));
$html .= sprintf('<textarea name="wpuf_files_data[%d][desc]" placeholder="%s">%s</textarea>', $attach_id, __('Description', 'wpuf'), esc_textarea($attachment->post_content));
$html .= '</div>';
}
$html .= sprintf('<input type="hidden" name="wpuf_files[%s][]" value="%d">', $type, $attach_id);
$html .= sprintf('<div class="caption"><a href="#" class="btn btn-danger btn-small attachment-delete" data-attach_id="%d">%s</a></div>', $attach_id, __('Delete', 'wpuf'));
$html .= '</li>';
return $html;
}
示例4: acf_input_admin_l10n
function acf_input_admin_l10n($l10n)
{
// append
$l10n['media'] = array('select' => __("Select", 'acf'), 'edit' => __("Edit", 'acf'), 'update' => __("Update", 'acf'), 'uploadedTo' => __("Uploaded to this post", 'acf'), 'default_icon' => wp_mime_type_icon());
// return
return $l10n;
}
示例5: aa_xml_mime_type_icon
function aa_xml_mime_type_icon($icon, $mime, $post_id)
{
if ($mime == 'application/xml' || $mime == 'text/xml' || $mime == 'application/tei+xml') {
return wp_mime_type_icon('document');
}
return $icon;
}
示例6: to_json
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Fields_API_Control::to_json()
*/
public function to_json()
{
parent::to_json();
$this->json['label'] = html_entity_decode($this->label, ENT_QUOTES, get_bloginfo('charset'));
$this->json['mime_type'] = $this->mime_type;
$this->json['button_labels'] = $this->button_labels;
$this->json['canUpload'] = current_user_can('upload_files');
$value = $this->value();
if (is_object($this->setting)) {
if ($this->setting->default) {
// Fake an attachment model - needs all fields used by template.
// Note that the default value must be a URL, NOT an attachment ID.
$type = in_array(substr($this->setting->default, -3), array('jpg', 'png', 'gif', 'bmp')) ? 'image' : 'document';
$default_attachment = array('id' => 1, 'url' => $this->setting->default, 'type' => $type, 'icon' => wp_mime_type_icon($type), 'title' => basename($this->setting->default));
if ('image' === $type) {
$default_attachment['sizes'] = array('full' => array('url' => $this->setting->default));
}
$this->json['defaultAttachment'] = $default_attachment;
}
if ($value && $this->setting->default && $value === $this->setting->default) {
// Set the default as the attachment.
$this->json['attachment'] = $this->json['defaultAttachment'];
} elseif ($value) {
$this->json['attachment'] = wp_prepare_attachment_for_js($value);
}
}
}
示例7: file_gallery_get_file_type
/**
* returns descriptive document type
* used for icons in attachment list
* both in backend and frontend
*
* needs more options and maybe a different approach...
* @deprecated since 1.7.4
*/
function file_gallery_get_file_type($mime)
{
return wp_mime_type_icon($mime);
if (false !== strpos($mime, "text") || false !== strpos($mime, "xhtml")) {
$type = "text";
} elseif (false !== strpos($mime, "excel")) {
$type = "spreadsheet";
} elseif (false !== strpos($mime, "powerpoint")) {
$type = "interactive";
} elseif (false !== strpos($mime, "code")) {
$type = "code";
} elseif (false !== strpos($mime, "octet-stream")) {
$type = "interactive";
} elseif (false !== strpos($mime, "audio")) {
$type = "audio";
} elseif (false !== strpos($mime, "video")) {
$type = "video";
} elseif (false !== strpos($mime, "stuffit") || false !== strpos($mime, "compressed") || false !== strpos($mime, "x-tar") || false !== strpos($mime, "zip")) {
$type = "archive";
} elseif (false !== strpos($mime, "application")) {
$type = "document";
} else {
$type = "default";
}
return apply_filters('file_gallery_get_file_type', $type, $mime);
}
示例8: json
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Fields_API_Control::to_json()
*/
public function json()
{
$json = parent::json();
$json['mime_type'] = $this->mime_type;
$json['button_labels'] = $this->button_labels;
$json['canUpload'] = current_user_can('upload_files');
$value = $this->value();
if (is_object($this->field)) {
if ($this->field->default) {
// Fake an attachment model - needs all fields used by template.
// Note that the default value must be a URL, NOT an attachment ID.
$type = 'document';
if (in_array(substr($this->field->default, -3), array('jpg', 'png', 'gif', 'bmp'))) {
$type = 'image';
}
$default_attachment = array('id' => 1, 'url' => $this->field->default, 'type' => $type, 'icon' => wp_mime_type_icon($type), 'title' => basename($this->field->default));
if ('image' === $type) {
$default_attachment['sizes'] = array('full' => array('url' => $this->field->default));
}
$json['defaultAttachment'] = $default_attachment;
}
if ($value && $this->field->default && $value === $this->field->default) {
// Set the default as the attachment.
$json['attachment'] = $json['defaultAttachment'];
} elseif ($value) {
$json['attachment'] = wp_prepare_attachment_for_js($value);
}
}
return $json;
}
示例9: widget
/**
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance)
{
// outputs the content of the widget
echo $args['before_widget'];
if (!empty($instance['title'])) {
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
}
$number_of_posts = -1;
if (!empty($instance['show_number_files'])) {
$number_of_posts = $instance['show_number_files'];
}
$orderby = 'date';
if (!empty($instance['sort_parameter'])) {
$orderby = $instance['sort_parameter'];
}
$order_direction = 'DESC';
if (!empty($instance['sort_direction'])) {
$order_direction = $instance['sort_direction'];
}
$exclude_ids = array();
if (!empty($instance['exclude_ids'])) {
$exclude_ids = $instance['exclude_ids'];
}
// TODO: get template choice. Echo css based on choice
echo '<style>.list_mediafiles_box{';
echo 'border: 1px solid #e2e2e2;';
echo 'margin: 5px;';
echo 'padding: 5px;';
echo '} .list_mediafiles_box img{';
echo 'max-width:100px;';
echo '} </style>';
$args = array('post_type' => 'attachment', 'numberposts' => $number_of_posts, 'post_status' => null, 'post_parent' => null, 'orderby' => $orderby, 'order' => $order_direction, 'exclude' => $exclude_ids);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $post) {
echo '<div class="list_mediafiles_box">';
setup_postdata($post);
echo '<h4>' . get_the_title($post->ID) . '</h4>';
switch ($post->post_mime_type) {
case 'image/jpeg':
case 'image/png':
case 'image/gif':
the_attachment_link($post->ID, false);
break;
default:
echo '<a href="' . get_attachment_link($post->ID) . '"><img src="' . wp_mime_type_icon($post->post_mime_type) . '"></a>';
}
echo '<span class="aligncenter" style="word-break:break-word;">';
the_excerpt();
echo '</span>';
echo '</div>';
}
}
//echo $args['after_widget'];
}
示例10: wpsc_select_product_file
/**
* Returns HTML for Digital Download UI
*
* @param int $product_id
* @return HTML
*/
function wpsc_select_product_file($product_id = null)
{
global $wpdb;
$product_id = absint($product_id);
$file_list = wpsc_uploaded_files();
$args = array('post_type' => 'wpsc-product-file', 'post_parent' => $product_id, 'numberposts' => -1, 'post_status' => 'all');
$attached_files = (array) get_posts($args);
$output = '<table id="wpsc_digital_download_table" class="wp-list-table widefat posts select_product_file">';
$output .= '<thead>';
$output .= '<tr>';
$output .= '<th>' . _x('Title', 'Digital download UI', 'wp-e-commerce') . '</th>';
$output .= '<th>' . _x('Size', 'Digital download UI', 'wp-e-commerce') . '</th>';
$output .= '<th>' . _x('File Type', 'Digital download UI', 'wp-e-commerce') . '</th>';
$output .= '<th id="wpsc_digital_download_action_th">' . _x('Actions', 'Digital download UI', 'wp-e-commerce') . '</th>';
$output .= '</tr>';
$output .= '</thead>';
$output .= '<tfoot>';
$output .= '<tr>';
$output .= '<th>' . _x('Title', 'Digital download UI', 'wp-e-commerce') . '</th>';
$output .= '<th>' . _x('Size', 'Digital download UI', 'wp-e-commerce') . '</th>';
$output .= '<th>' . _x('File Type', 'Digital download UI', 'wp-e-commerce') . '</th>';
$output .= '<th id="wpsc_digital_download_action_th">' . _x('Actions', 'Digital download UI', 'wp-e-commerce') . '</th>';
$output .= '</tr>';
$output .= '</tfoot>';
$num = 0;
$output .= '<tbody>';
$delete_nonce = _wpsc_create_ajax_nonce('delete_file');
foreach ((array) $attached_files as $file) {
$file_dir = WPSC_FILE_DIR . $file->post_title;
$file_size = 'http://s3file' == $file->guid ? __('Remote file sizes cannot be calculated', 'wp-e-commerce') : wpsc_convert_byte(filesize($file_dir));
$file_url = add_query_arg(array('wpsc_download_id' => $file->ID, '_wpnonce' => wp_create_nonce('wpsc-admin-download-file-' . $file->ID)), admin_url());
$deletion_url = wp_nonce_url("admin.php?wpsc_admin_action=delete_file&file_name={$file->post_title}&product_id={$product_id}&row_number={$num}", 'delete_file_' . $file->post_title);
$class = !wpsc_is_odd($num) ? 'alternate' : '';
$file_type = get_post_mime_type($file->ID);
$icon_url = wp_mime_type_icon($file_type);
$output .= '<tr class="wpsc_product_download_row ' . $class . '">';
$output .= '<td style="padding-right: 30px;"><img src="' . $icon_url . '"><span>' . $file->post_title . '</span></td>';
$output .= '<td>' . $file_size . '</td>';
$output .= '<td>' . $file_type . '</td>';
$output .= '<td><a href="' . esc_url($file_url) . '">' . _x('Download', 'Digital download row UI', 'wp-e-commerce') . '</a><a data-file-name="' . esc_attr($file->post_title) . '" data-product-id="' . esc_attr($product_id) . '" data-nonce="' . esc_attr($delete_nonce) . '" class="file_delete_button" href="' . $deletion_url . '" >' . _x("Delete", "Digital download row UI", 'wp-e-commerce') . '</a></td>';
$output .= '</tr>';
$num++;
}
$output .= '</tbody>';
$output .= '</table>';
if (empty($attached_files)) {
$output .= "<p class='no-item'>" . __('There are no files attached to this product. Upload a new file or select from other product files.', 'wp-e-commerce') . "</p>";
}
$output .= "<div class='" . (is_numeric($product_id) ? 'edit_' : '') . "select_product_handle'></div>";
$output .= "<script type='text/javascript'>\r\n";
$output .= "var select_min_height = " . 25 * 3 . ";\r\n";
$output .= "var select_max_height = " . 25 * ($num + 1) . ";\r\n";
$output .= "</script>";
return $output;
}
示例11: getThumbnail
/**
* Get thumbnail URL for document with given ID from default images.
*
* @param string $ID The attachment ID to retrieve thumbnail from.
* @param int $pg Unused.
*
* @return string URL to thumbnail.
*/
public function getThumbnail($ID, $pg = 1)
{
static $image_exts = array('jpg', 'jpeg', 'gif', 'png');
$icon_url = DG_URL . 'assets/icons/';
$ext = self::getExt(wp_get_attachment_url($ID));
// handle images
if (in_array($ext, $image_exts) && ($icon = self::getImageThumbnail($ID))) {
// Nothing to do
} elseif ($name = self::getDefaultIcon($ext)) {
// try DG custom default icons first
$icon = $icon_url . $name;
// then fall back to standard WP default icons
} elseif (!($icon = wp_mime_type_icon($ID))) {
// everything failed. This is bad...
$icon = $icon_url . 'missing.png';
}
return $icon;
}
示例12: attach_html
public static function attach_html($attach_id, $custom_attr = [])
{
$attachment = get_post($attach_id);
if (!$attachment) {
return;
}
if (wp_attachment_is_image($attach_id)) {
$image = wp_get_attachment_image_src($attach_id, array('80', '80'));
$image = $image[0];
} else {
$image = wp_mime_type_icon($attach_id);
}
$html = '<li class="erp-image-wrap thumbnail">';
$html .= sprintf('<div class="attachment-name"><img class="erp-file-mime" ' . implode(' data-', $custom_attr) . ' height="80" width="80" src="%s" alt="%s" /></div>', $image, esc_attr($attachment->post_title));
$html .= sprintf('<input type="hidden" name="files[]" value="%d">', $attach_id);
$html .= sprintf('<div class="caption"><a href="#" class="erp-del-attc-button btn-danger btn-small attachment-delete" data-attach_id="%d">X</a></div>', $attach_id);
$html .= '</li>';
return $html;
}
示例13: attach_html
public static function attach_html($attach_id, $type = NULL)
{
if (!$type) {
$type = isset($_GET['type']) ? $_GET['type'] : 'image';
}
$attachment = get_post($attach_id);
if (!$attachment) {
return;
}
if (wp_attachment_is_image($attach_id)) {
$image = wp_get_attachment_image_src($attach_id, 'thumbnail');
$image = $image[0];
} else {
$image = wp_mime_type_icon($attach_id);
}
$html = '<li class="image-wrap thumbnail" style="width: 150px">';
$html .= sprintf('<div class="attachment-name"><img src="%s" alt="%s" /></div>', $image, esc_attr($attachment->post_title));
$html .= sprintf('<div class="caption"><a href="#" class="btn btn-danger btn-small attachment-delete" data-attach_id="%d">%s</a></div>', $attach_id, __('Delete', 'wpuf'));
$html .= sprintf('<input type="hidden" name="wpuf_files[%s][]" value="%d">', $type, $attach_id);
$html .= '</li>';
return $html;
}
示例14: to_json
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
*
* highly based on WP_Customize_Media_Control merged with WP_Customize_Upload_Control ::to_json()
*/
public function to_json()
{
$this->json['mime_type'] = $this->mime_type;
$this->json['button_labels'] = $this->button_labels;
$this->json['bg_repeat_options'] = $this->bg_repeat_options;
$this->json['bg_attachment_options'] = $this->bg_attachment_options;
$this->json['bg_position_options'] = $this->bg_position_options;
$this->json['canUpload'] = current_user_can('upload_files');
$this->json['default_model'] = $this->default_model;
$value = $this->value();
if (isset($this->setting) && is_object($this->setting)) {
$_defaults = isset($this->setting->default) ? $this->setting->default : null;
$default_bg_img = isset($_defaults['background-image']) ? $_defaults['background-image'] : null;
}
$default_bg_im = isset($default_bg_img) ? $default_bg_img : null;
if ($default_bg_img) {
// Fake an attachment model - needs all fields used by template.
// Note that the default value must be a URL, NOT an attachment ID.
$type = in_array(substr($default_bg_img, -3), array('jpg', 'png', 'gif', 'bmp', 'svg')) ? 'image' : 'document';
$default_attachment = array('id' => 1, 'url' => $default_bg_img, 'type' => $type, 'icon' => wp_mime_type_icon($type), 'title' => basename($default_bg_img));
$default_attachment['sizes'] = array('full' => array('url' => $default_bg_img));
$this->json['defaultAttachment'] = $default_attachment;
}
$background_image = isset($value['background-image']) ? $value['background-image'] : null;
if ($background_image && $default_bg_img && $background_image === $default_bg_img) {
// Set the default as the attachment.
$this->json['attachment'] = $this->json['defaultAttachment'];
} elseif ($background_image) {
$attachment_id = attachment_url_to_postid($background_image);
if ($attachment_id) {
$this->json['attachment'] = wp_prepare_attachment_for_js($attachment_id);
} else {
//already an id
$this->json['attachment'] = wp_prepare_attachment_for_js($background_image);
}
}
parent::to_json();
}
示例15: xt_manage_post_custom_column
function xt_manage_post_custom_column($column, $post_id)
{
switch ($column) {
case 'icon':
$att_title = _draft_or_post_title();
?>
<a href="<?php
echo esc_url(get_edit_post_link($post_id, true));
?>
" title="<?php
echo esc_attr(sprintf(__('Edit “%s”', XT_TEXT_DOMAIN), $att_title));
?>
"><?php
if ($thumb = get_the_post_thumbnail($post_id, array(80, 60))) {
echo $thumb;
} else {
echo '<img width="46" height="60" src="' . wp_mime_type_icon('image/jpeg') . '" alt="">';
}
?>
</a>
<?php
break;
}
}